graysky Posted April 9, 2005 Share Posted April 9, 2005 Can someone tell me how I can add a right-click menu item that will simply run a batch file in the directory I right-click? I know how to do this with a file, but not a directory.For files, I my send to notepad tweak is as follows:[HKEY_CLASSES_ROOT\*\Shell][HKEY_CLASSES_ROOT\*\Shell\Send to Notepad][HKEY_CLASSES_ROOT\*\Shell\Send to Notepad\Command]@="notepad.exe %1"In my example, I have a batch file called "dogain.bat" and I would like it to run in a whatever directory the user right-clicks and then selects the option (let's call it "do replaygain") from the pop-up menu.Any help is appreciated!Thanks! Link to comment Share on other sites More sharing options...
graysky Posted April 10, 2005 Author Share Posted April 10, 2005 Man, only 17 reads in a day? I think I'm on my own with this one Link to comment Share on other sites More sharing options...
Yzöwl Posted April 10, 2005 Share Posted April 10, 2005 (edited) [HKEY_CURRENT_USER\Software\Classes\Folder\shell\do replaygain][HKEY_CURRENT_USER\Software\Classes\Folder\shell\do replaygain\command]@="\"C:\\My Bats\\dogain.bat\" \"%1\""Just change the location of the bat as required, and you can replace \Folder\ with \Directory\, if you prefer.You can change the HKEY_CURRENT_USER\Software\Classes, for HKEY_LOCAL_MACHINE\SOFTWARE\Classes, if your tweak is for all users. This would be the same as HKEY_CLASSES_ROOT, but you should try to avoid directly going there; all HKLM\SOFTWARE\Classes entries are mapped to HKCR. Edited April 10, 2005 by Yzöwl Link to comment Share on other sites More sharing options...
graysky Posted April 10, 2005 Author Share Posted April 10, 2005 Firstly, thanks for the help I copied your code into a "dogain.reg" file like so:REGEDIT4[HKEY_CURRENT_USER\Software\Classes\Folder\shell\do replaygain][HKEY_CURRENT_USER\Software\Classes\Folder\shell\do replaygain\command]@="\"C:\My Bats\dogain.bat\" \"%1\""And then merged it with my registry. (I also moved the files to c:\my bats to keep it simple.) When I looked at the resulting registry in regedit, the last line of the batch file is no where in sight... what did I do wrong? Link to comment Share on other sites More sharing options...
Yzöwl Posted April 10, 2005 Share Posted April 10, 2005 My mistake, I've re-edited my previous post correctly.(note the double backslashes) Link to comment Share on other sites More sharing options...
graysky Posted April 10, 2005 Author Share Posted April 10, 2005 Cool... looks fine from the registry now; however when I right-click a dir and select the "do replaygain" option, a dos window opens and closes too fast for me to read the error message. I can't tell what's happening but the batch file should take a good 30-50 seconds to complete when run from commandline. Any ideas how I can add a wait or something so I can debug?Thanks again! Link to comment Share on other sites More sharing options...
Yzöwl Posted April 10, 2005 Share Posted April 10, 2005 Either post the batch file or paste it into a PM, if you prefer. My guess is that you just need a few adjustments to take %1. Link to comment Share on other sites More sharing options...
graysky Posted April 10, 2005 Author Share Posted April 10, 2005 Sent via PM .. once we (you) figure it out, I'll post the relevant info in case others are interested. Link to comment Share on other sites More sharing options...
seapagan Posted April 10, 2005 Share Posted April 10, 2005 Any ideas how I can add a wait or something so I can debug?<{POST_SNAPBACK}>Just add a 'pause' command at the end of the batch file, this will allow you to see any errors before the window closes.without seeing the batch file, your problem may be to do with directories that have spaces in them, or not picking up the full path properly.SP Link to comment Share on other sites More sharing options...
graysky Posted April 10, 2005 Author Share Posted April 10, 2005 I think I found the problem: when I right click a dir anywhere in a given drive, the batch file tries to run on the root drive -- not the dir I'm rightclicking. In other words, I rightlcik e:\work and select the command from the pop-up. The result is that the batch file runs on e:\ Likewise, if I right-click d:\temp\album and select the command from the pop-up, the result is that the batch file runs on d:\Took me a while to figure it out but that's the case... is there something wrong with the reg key syntax that wouldn't pass on the full path to the batch file? Link to comment Share on other sites More sharing options...
Yzöwl Posted April 10, 2005 Share Posted April 10, 2005 The problem is not in the registry entry, but in your batch file.The batch file will very likely still be running in its own directory, i.e C:\My BatsAs a simple fix, I would just make sure that your batch is in the directory upon which you clicked. To do this the batch would probably need to start with a line something like@echo offCD %1 Link to comment Share on other sites More sharing options...
graysky Posted April 10, 2005 Author Share Posted April 10, 2005 Works like a charm now, thanks!BTW, do you know of a resource that will list all the different vars one can use in a batch file (like %1 for example)?Thanks again! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now