Jump to content

[help] executing a program through cmd.exe ...


dr.zick

Recommended Posts

first off is this possible ... my initial attempts have not worked.

what i want to do is open the command prompt and execute a command line program, by right-clicking a file. so i would have to add a command to a file classes verb (cmd.exe /c "command") ... a real practical example is encoding or decoding wave files into other other formats using command-line apps like lame or flac. i want to be able to encode a wave file from a right-click.

this is as far as i've gotten: cmd.exe /c "flac -s -V --best %1" but this isn't working ...

any thoughts ... much thanx and appreciation.

Edited by dr.zick
Link to comment
Share on other sites


you can just add a new file type for this. open up any explorer window and go to tools>folder options>file types and select a new file type and extension etc and point it at your flac.exe in your flac directory (by using the advanced tab)

you can then add extra command lines that flac will understand (still using inverted commas if there's spaces in there) and you can also click what action - ie right click or double click or shift-click etc- activates this command

Edited by haggisnneeps
Link to comment
Share on other sites

Firstly, there's no need to use cmd.exe. You should specify the direct path to the program. If the path contains spaces, you should enclose it in double quotes. Also, since most often than not %1 will also contain spaces so you must enclose that too in double quotes.

For eg:

"C:\Program Files\flac\flac.exe" -s -V --best "%1"

And if for some reason you need to run something thru cmd.exe, don't point it to cmd.exe directly, instead point it to a batch file:

"C:\Some Path\mybatch.cmd" "%1"

mybatch.cmd can then contain simple stuff like:

myprogram.exe -my -parameters %1%

And just to confirm, this is the proper registry path:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\exefile\shell\name in your context menu\command

replace exefile with the desired file extension you want your context menu command to be associated with. For eg, to make it appear for AVI files, replace exefile by AVIfile, and so on. Of course, make sure that the extension is registered in the first place under \Classes.

For more clarity, have a look at some of your existing shell extensions like for eg for AVI or EXE files.

Link to comment
Share on other sites

sweet ... i got it working, but i had to fudge abit since my progams are in different places.

i tried calling flac originally (in my first attempt) but it didn't work. must have been a typo. i didn't realize the quoted areas were places with spaces, but now it makes sense.

i appreciate the help.

Link to comment
Share on other sites

hey do i have to use a direct path or can i use a %SYSTEMROOT%\flac.exe with an expandable string?

thanx ... the first one worked i just like using %SYSTEMROOT%'s %PROGRAMFILES%'s if i can ... and when i played around with that type of string, it didn't seem to work.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...