running batch file without extension

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
bouchta
Posts: 7
Joined: 21 Jul 2011 13:31

running batch file without extension

#1 Post by bouchta » 22 Jul 2011 14:48

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

Acy Forsythe
Posts: 126
Joined: 10 Jun 2011 10:30

Re: running batch file without extension

#2 Post by Acy Forsythe » 22 Jul 2011 17:11

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...

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: running batch file without extension

#3 Post by dbenham » 22 Jul 2011 17:22

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

bouchta
Posts: 7
Joined: 21 Jul 2011 13:31

Re: running batch file without extension

#4 Post by bouchta » 23 Jul 2011 05:49

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 :!: :?:

Post Reply