Re: How to pass short filename in context menu?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: David Candy (.)
Date: 11/26/04


Date: Fri, 26 Nov 2004 12:36:14 +1100

You are wrong

%1 passes long file names to 32 bit programs and Win 95 aware 16 bit programs. It passes shortfile names to 16 bit non win95 aware programs AND also to programs it can't find.

So in the command field in the registry change the path to cmd to something explorer can't find. Normally this occurs if the program's name is not enclosed in quotes (and there's spaces in the path).

Note Explorer builds a command line then gives it to CreateProcess to execute. Just because Explorer can't find a file doesn't mean CreateProcess can't. Try removing the path or something. MS refuse to say what Explorer's search alogarthm is (I suspect it just looks one place). CreatProcess' is well known and detailed below. I just add that it tries all ambigious paths as well..

This behaviour won't be chaged as some programs rely on this behaviour. MS did fix it but had to unfix it after application testing.

So in short there is no official way to force a shortname to be passed.

If the file name does not contain a directory path, the system searches for the executable file in the following sequence:
  1.. The directory from which the application loaded.
  2.. The current directory for the parent process.
  3.. Windows 95/98/Me: The Windows system directory. Use the GetSystemDirectory function to get the path of this directory.
  Windows NT/2000/XP: The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is System32.

  4.. Windows NT/2000/XP: The 16-bit Windows system directory. There is no function that obtains the path of this directory, but it is searched. The name of this directory is System.
  5.. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
  6.. The directories that are listed in the PATH environment variable.

-- 
----------------------------------------------------------
http://www.uscricket.com
<nospam.please@ualberta.ca> wrote in message news:cnvtd0$gl8$1@tabloid.srv.ualberta.ca...
> In earlier versions of Windows, using %1 would pass the short filename, and %L 
> would pass the long filename in a context menu shell command.
> 
> In WinXP, all parameters seem to pass the long filename.  Is there any way to 
> get the short filename?
> 
> I can do something like pass the long filename to a CMD file which then uses 
> %~s1 to pass the short filename on to the actual desired command, but this is 
> a bit of a kludge job.


Relevant Pages

  • Re: What is the difference between CMD and BAT file ?
    ... ..CMD will be listed in PATHEXT under Set in NT in a command prompt and will ... NOT be listed under non NT i.e. Windows 9x, Me, etc. ... Files of .bat will be listed in the File Types dialog box as MS-DOS Batch ...
    (microsoft.public.windowsxp.general)
  • Re: How To Execute Batch File Line By Line
    ... COMMAND /C string Carries out the command specified by string, ... CMD /C Carries out the command specified by string and then terminates. ... .cmd files will NOT work on non Windows NT versions i.e. Windows 9x, ... Both .cmd and .bat files work on Windows NT versions. ...
    (microsoft.public.windowsxp.general)
  • Re: How To Execute Batch File Line By Line
    ... COMMAND /C string Carries out the command specified by string, ... CMD /C Carries out the command specified by string and then terminates. ... Both .cmd and .bat files work on Windows NT versions. ... File Description MS-DOS Batch File ...
    (microsoft.public.windowsxp.general)
  • Re: Quando Apple lascia le cose al caso...
    ... " keep a backup file ... " make all windows the same size when adding/removing windows ... " remove '=' from the list of valid filename chars. ...
    (it.comp.macintosh)
  • Re: What is the difference between CMD and BAT file ?
    ... I have two .cmd files that are part of XP. ... my understanding is that BAT can be applied to both NT ... NOT be listed under non NT i.e. Windows 9x, Me, etc. ... typed in a Command Prompt or the Run command. ...
    (microsoft.public.windowsxp.general)