« If it walks like a duck... | National Federation of the Blind = Spammers » |
Working with the Windows ShellExecute and ShellExecuteEx APIs and the CreateProcess API I have come across a major annoyance:
The directory and filename passed into these APIs can not be longer than MAX_PATH (i.e., 260) characters.
This is particularly idiotic given that Microsoft nowadays uses fairly long directory names, e.g., C:\Documents and Settings\All Users\Application Data.
Furthermore, the ShellExecute(Ex) documentation does not even state this limit.
Anyway, I did find a way around it:
Microsoft maintains both long and short names for files and directories, even on NTFS.
So, the long path C:\Documents and Settings\All Users\Application Data is equivalent to the short path C:\Docume~1\alluse~1\applic~1
This way, the path to the batch file I was trying to execute was cut down from 261 characters to 106 characters.