Quantcast
Channel: How to create a folder in C:\ so that it has the same shortname as "C:\Program Files" would? - Super User
Viewing all articles
Browse latest Browse all 2

Answer by grawity for How to create a folder in C:\ so that it has the same shortname as "C:\Program Files" would?

$
0
0

It will never become PROGRA~1 as long as you already have another directory named that.

Short names are persistent – they're chosen when creating the object and stored within the filesystem just like regular names. Once the name has been assigned, neither alphabetical order nor modification timestamps will cause it to change. (After all, they're supposed to work like regular names, which includes not having the name suddenly change on its own.)

The Win32 API has a function SetFileShortName() which lets you directly change the 8.3 names of any path, so write a short program (or use Python ctypes, etc) to perform this change.

(After changing the short name of "Program Files" to something custom, you can create a directory literally named PROGRA~1 if that's what the program needs. You don't need to craft a special name to trick the algorithm.)

Alternatively, you could rename "Program Files" to "asdf", freeing up its short name. Then, once "PROGRA~1" is claimed by your directory, rename the real one back to "Program Files" and it'll be assigned ~2.


Viewing all articles
Browse latest Browse all 2

Trending Articles