Page 1 of 1
running batch file without extension
Posted: 22 Jul 2011 14:48
by bouchta
please is there a way to run a batch file without the trailing .bat or .exe or any other extension than .bat or .cmd like
Code: Select all
cmd.exe "c:\imcmdfile"
cmd.exe "c:\cmdfile.whateverextension"
is it possible
thanks
Re: running batch file without extension
Posted: 22 Jul 2011 17:11
by Acy Forsythe
Have you tried it?
If you have multiple files with the same name you could run into problems but yes you can run a command or executable without the .exe or .bat, etc...
Re: running batch file without extension
Posted: 22 Jul 2011 17:22
by dbenham
Acy Forsythe wrote:Have you tried it?
If you have multiple files with the same name you could run into problems but yes you can run a command or executable without the .exe or .bat, etc...
If the batch file has a .BAT extension, then of course you don't need to include the extension when you call it.
But I think the question is, does a batch file have to have a .BAT or .CMD extension in order for it to be interpreted as a batch script
(We are talking the file itself, not the call)
Maybe there is a file association that can be made in the registry somewhere, but othererwise, I don't think it can be done for batch scripts. I think they need .BAT or .CMD extensions.
Dave Benham
Re: running batch file without extension
Posted: 23 Jul 2011 05:49
by bouchta
Acy Forsythe wrote:
Have you tried it?
i really tried harder to run it,trying to pass the script file to cmd.exe as a parameter,it just start the file without interpreting it or start the cmd itself
benham wrote:But I think the question is, does a batch file have to have a .BAT or .CMD extension in order for it to be interpreted as a batch script (We are talking the file itself, not the call)
Maybe there is a file association that can be made in the registry somewhere, but othererwise, I don't think it can be done for batch scripts. I think they need .BAT or .CMD extensions.
i create a custom registry key something like
Code: Select all
HKEY_CLASSES_ROOT\.whateverext
@="whateverextfile"
HKEY_CLASSES_ROOT\whateverextfile\shell\open\command
@="cmd.exe \"%1\" "
i run the file "c:\script.whateverext" and the cmd window show up run for a little seconds,and then i hear the sound of error and it crashes or cmd windows remains and no interpretation is done
i just noticed some hex values that i think run the interpretation
Code: Select all
[HKEY_CLASSES_ROOT\cmdfile\shellex]
[HKEY_CLASSES_ROOT\cmdfile\shellex\DropHandler]
@="{86C86720-42A0-1069-A2E8-08002B30309D}"
[HKEY_CLASSES_ROOT\cmdfile\shellex\PropertySheetHandlers]
[HKEY_CLASSES_ROOT\cmdfile\shellex\PropertySheetHandlers\PifProps]
@="{86F19A00-42A0-1069-A2E9-08002B30309D}"
[HKEY_CLASSES_ROOT\cmdfile\shellex\PropertySheetHandlers\ShimLayer Property Page]
@="{513D916F-2A8E-4F51-AEAB-0CBC76FB1AF8}"
any idea maybe how to change those hex values or any method to make any other file with any wanted extension to be interpreted properly by cmd.exe directly