Tagged: short path convert long path
August 30, 2017 at 1:04 am #78367
How can I convert short paths to long paths within PowerShell which is a path from command ?
August 30, 2017 at 3:49 am #78370
Sorry Christopher, but the description of your issue is a little vague. However, hopefully I've understood it and maybe the following might help. If not, if you can give more details that might help.
August 30, 2017 at 9:46 am #78377
Assuming you are talking about converting .\FileName.txt to C:\Path\To\Console\Location\FileName.txt you would do the following:
$LiteralPath = Convert-Path -Path $Path
August 30, 2017 at 10:47 pm #78452
August 30, 2017 at 11:11 pm #78457
In the example at that link, $path is the short 8.3 format (Ex: c:\progra~1).
$path = "c:\progra~1"
$long_path = (Get-Item -LiteralPath $path).FullName
August 31, 2017 at 1:04 am #78466
@Kevyn – thanks. Can powershell tie into command prompt (dos). Run a command in command prompt and it executes a powershell command and back to command prompt ?
What Liam posted, if $LiteralPath is the 8.3 file path, what is Convert-Path Job ?
August 31, 2017 at 12:25 pm #78506
Guys ... please ... there is no DOS anymore for over 20 years. The proper name is command prompt. I wouldn't mind to hear / read command windows or command console but please not DOS!
Can powershell tie into command prompt (dos). Run a command in command prompt and it executes a powershell command and back to command prompt ?
@ Christopher: Try the following command in a command prompt or Powershell console window:
May I ask what you actually want to achieve? As far as I know there is no need anymore for a very long time to use 8.3 names for something reasonable.
August 31, 2017 at 2:01 am #78472
Not sure I follow your question, but PowerShell can run DOS commands like Dir.
As for Convert-Path, it doesn't convert the 8.3 format file paths to the long/full paths. Run the following command to see details on what it does, including examples.
Get-Help Convert-Path -Full
August 31, 2017 at 2:24 am #78478
@Kevyn – I assume you don't use DOS and have made powershell your primary tool for working within windows ?
August 31, 2017 at 3:45 am #78481
I switch between them, but I don't really run a ton in DOS beyond Dir, Ipconfig, NSLookup, etc... I'm starting to make PowerShell my default since it, as far as I know, can do anything DOS command prompt can do.
August 31, 2017 at 8:56 am #78493
I apologize. I thought you were referring to relative paths when you mentioned 'short paths'. Convert-Path will take a relative path and give you the fully qualified path.
September 8, 2017 at 12:52 am #79058
Long delay, I tried to login with my old account five times; I attempted to recover my password more then eight times in all attempts no email was sent to the registered email account ? I had to create another account to reply to my post and inform the moderators if they can merge my old account with this account ?
Onto my question.
Since I cannot directly work with a command for a program I use as it only works in command, rather then powershell, unless I can ? In other words; is it possible to work with a command which strictly works only in command within powershell ? I'm relatively new at powershell but not command console.
What I'm hoping I can do is access the program command rather then within command console but powershell then do as mentioned in this thread, such as list the full path rather then what command lists which is a abbreviated path.
September 8, 2017 at 7:39 am #79070
September 8, 2017 at 3:48 am #79060
Let me see if I understand you correctly. There is some application/executable file that you're saying only works for you when you run it from a command prompt and that the application/executable file outputs the 8.3 path format that you're then wanting to get the full path for? What, exactly, is the file you're running (Ex: program.exe) and the command syntax (Ex: Program.exe /blah /blah) you're trying to get to work in PowerShell?
September 9, 2017 at 12:38 am #79174
Let me see if I understand you correctly. There is some application/executable file that you're saying only works for you when you run it from a command prompt and that the application/executable file outputs the 8.3 path format that you're then wanting to get the full path for?
Yes, that is correct.
I ran Start-Process which which asks for a path, I supplied the path of the executable file, although when running the executable file I get the error;
Is not a recognized as the name of a cmdlet, function,script file, check the spelling of the name, of if a path was included etc.
Although I entered in the correct path and executable file ?
September 9, 2017 at 2:30 am #79175
What is the exact Start-Process command you're running?
September 9, 2017 at 2:35 am #79178
I simply ran the command Start-Process which followed by asking the path of the executable file; that's all I had done ?
September 9, 2017 at 8:48 am #79193
I would reccomend for you to take step back and start by learning the basics of Powershell in a comprehensive and sustainable way. It will keep you away from a lot of frustration and guessing. That's not a professional way to approach a problem.
In the following post you can find some good and mostly free sources to start with:
You must be logged in to reply to this topic.