Short File Name Won't Execute

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Jun 2, 2008
284
1
Newton, MA
#1
I have the environment variable ".pdf" defined to be "reader", which invokes Adobe Reader. If I enter a long file name that ends with ".pdf" as a command on the command line, the file opens in Reader. However, if I enter the short file name,

C:\Users\Jay\DOCUME~1\JG157F~1.PDF​

I get an error message that the command is not recognized. Is this an expected limitation of short file names with executable extensions?
 
Jun 2, 2008
284
1
Newton, MA
#3
Do you have "Search for SFNs" turned off?
Thanks. I'm sure that's it (it is). And I don't think I want to change that setting.

What's interesting is that short directory names are processed; it seems to be only files that are not found using the short name.

As you might guess, this is all related to my attempts to mitigate the horrendous practice of using spaces in directory and file names. My initial solution was to automatically add quotes around files and directories with spaces, but problems occur when trying to make changes, such as adding a file name to the end of a directory name enclosed in quotes. So I thought it was clever to just use the short file names. Back to the drawing board.

In my script to put a directory path into the clipboard, I'm leaving the conversion to the short name, but I'll leave file names alone.
 
#4
However, if I enter the short file name,

C:\Users\Jay\DOCUME~1\JG157F~1.PDF​

I get an error message that the command is not recognized. Is this an expected limitation of short file names with executable extensions?
I have run across problems with filenames containing spaces so often that I've gotten into the habit of using "start /pgm" to launch many programs. I wonder: in defining the executable extension, can you precede the name of the executable with "start /pgm" -- would that help?
 
#5
I see (and discover) the same behavior:
- it doesn't work as the verb, it doesn't work with DIR ("Search for SFN" checked or not),
- it works with START/PGM, it works as an argument to a PDF-viewer, it even works as an argument to an unrelated program (e.g. my text editor will correctly open it and display the long filename) (both my PDF-viewer and my editor are 32 bit executables).

Concerning the issue of “adding a file name to the end of a directory name enclosed in quotes”, the @full function seems to do the job now.