short paths to long paths

How can I convert short paths to long paths within PowerShell which is a path from command ?

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.

https://technet.microsoft.com/en-us/library/ee692752.aspx
https://blogs.msdn.microsoft.com/sergey_babkins_blog/2015/04/01/how-to-convert-a-short-8-3-path-name-to-a-long-path-name-in-powershell/

Hi Christopher,

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

Liam

@Liam Fisher the flag -Path and $Path, which of these two paths must I supply the 8.3 file path ?

@Kevyn this link. I’m not quite sure which flag I need to supply the 8.3 file path ?

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
$long_path

C:\Program Files

@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 ?

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

@Kevyn - I assume you don’t use DOS and have made powershell your primary tool for working within windows ?

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.

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.

Liam

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:
powershell /?

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.

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.

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?

Did you try Start-Process? … with the right parameters of course …

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 ?

What is the exact Start-Process command you’re running?

I simply ran the command Start-Process which followed by asking the path of the executable file; that’s all I had done ?

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:
https://powershell.org/forums/topic/using-csv-files/