I want to include the path to a library in the Program Files directory, but I need to do this without spaces. I know that Windows uses a convention that shortens names like Program Files becomes PROGRA~1. How can I find these shortened names for an arbitrary directory?

(Apologies if this has already been asked but I couldn't find it.)

link|improve this question

Can't you just use quotation marks so you can leave the spaces in place? e.g., "C:\Program Files" – Uninspired Dec 2 '10 at 0:56
feedback

3 Answers

up vote 10 down vote accepted

You can use for each folder:

DIR /X
link|improve this answer
Thanks! That worked! – Shane Aug 23 '10 at 13:47
1  
also don't forget dir /x /a for hidden files – Drew LeSueur Aug 5 '11 at 9:06
feedback

in cmd, go to required directory and type dir/x to see the shortened name for your required folder

link|improve this answer
feedback

There is a better way to reference the Program Files folder : use the %PROGRAMFILES% variable. And there is no spaces in it :).
For instance : %PROGRAMFILES%\MyLib\MyLib.dll

link|improve this answer
feedback

protected by Diago Dec 2 '10 at 7:24

This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.

Not the answer you're looking for? Browse other questions tagged or ask your own question.