Windows path without spaces (with ~1)?

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.)


You can use for each folder:

DIR /X

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


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