Skip to content

Windows – GetShortPathName

July 31, 2013

Many times we face problem due to space in windows file or folder path. Windows provide GetShortPathName  api to get short path name from the long name. Sometime we need to quickly find out short name while middle to doing something. We can use windows power shell to find that out quickly. Here is quick code to do that,

1) Create filesystem object


$a = New-Object -ComObject Scripting.FileSystemObject

2)  Get the directory or file object


$f = $a.GetFolder("C:\Program Files\MySQL\MySQL Server 5.1\bin")

3) Print the short path


$f.ShortPath

That’s all you need to do, to get the short path from long path.

Advertisements

From → Tech

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: