Short filenames sent to batch file through context menu

Y

Yan Bilik

Hello,

I have written a simple test batch file (let's say c:\test.cmd), which
contains the following commands:
---------
@echo %1
pause
---------

I have also written a Reg file and merged it to the registry:
---------
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\xmlfile\shell\test]
@="test"

[HKEY_CLASSES_ROOT\xmlfile\shell\test\command]
@="CMD.EXE /c c:\test.cmd %1"
---------

The aim is to get a new context menu named "test" when I right click an
XML file.

Under Windows 2000, it works fine with any kind of file. But under
Windows XP Pro, if I launch that new menu item for a long filename, my
batch receive the *short* corresponding filename, and I found no way to
get the long filename back...

Example:
- file is c:\temp\alongfilename.xml
- right-click it, choose "test"
- a command-line window is opened and displays
c:\temp\ALONGF~1.XML
Hit any key...


Note another strange thing: it works fine (i.e. I got the longfilename)
if I call the command from a command-line window:
C:> CMD.EXE /c c:\test.cmd c:\temp\alongfilename.xml
c:\temp\alongfilename.xml
Hit any key...

Any idea ?

Yan
 
D

David Candy

\"%L\"

\ escapes the " and you'll need " if it's a long file name.

I get long file names. I don't use cmd /c (as bat are executable in their own right).
 
Y

Yan Bilik

David said:
\"%L\"

\ escapes the " and you'll need " if it's a long file name.

I get long file names. I don't use cmd /c (as bat are executable in their own right).

Thanks a lot, David ! I've googled a lot before posting, and found
noting about this setting !
Regards,

Yan
 
A

Alex Nichol

Yan said:
I have written a simple test batch file (let's say c:\test.cmd), which
contains the following commands:
---------
@echo %1
pause
---------

I have also written a Reg file and merged it to the registry:
---------
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\xmlfile\shell\test]
@="test"

[HKEY_CLASSES_ROOT\xmlfile\shell\test\command]
@=

Put the %1 in the registry entry into quotes
"CMD.EXE /c c:\test.cmd "%1""
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top