windowsregistryshellexecute

How to prevent use of 8.3 names in HKCR open commands?


I tried to modify the open default command for .bat and .cmd files on Windows in order to open the Windows terminal instead of the legacy cmd.exe.

My modification to the user registry was:

Screenshot of registry modification

(I had to use TotalReg from Pavel Yosifovitch to change the default value to REG_EXPAND_SZ).

The same default value was used for the batfile class.

The above definitions work almost properly.
There is a little issue though: when I now run a .bat or a .cmd file, the command line for wt.exe uses “legacy DOS 8.3 paths”, as well as the current working directory.

If my definition for the open command simply uses wt.exe instead of "%localappdata%\Microsoft\WindowsApps\wt.exe", then the problem disappears.

Is there a way to use the absolute path and still get the non-8.3 behavior?


Solution

  • When using %1, the shell tries to guess if the target supports long filenames. If you use %L, the shell always uses the long filename if the target is 32 or 64-bit. 16-bit applications presumably still get the short name?

    %L is not officially documented anywhere but a Microsoft employee listed them in a comment here...