Jump to content

Hook my program to context menu via batch file.

Go to solution Solved by HeftyNugget,

Nevermind, got it working - here's how it's done for others who stumble upon this post.
 

@echo off

SET fpath=D:\Program\Program.exe

echo "This is the path %fpath%"

rem add item to folder context menu
@reg add "HKCR\Directory\shell\Open with Program"				/t REG_SZ /v "" /d "Open with Program" /f
@reg add "HKCR\Directory\shell\Open with Program\command"		/t REG_SZ /v "" /d "%fpath% "-path" "%%1" /f

pause

 

Well, straight to the point.
I've made a small program and I want it hooked to context menu, so upon clicking 'Open in MyProgram' it runs it with command lines "-path path_to_clicked_folder".

I know that you can edit registry to add this, but I want it in a .batch file so people downloading my program can hook it to their context menu by just running the script.

If anybody has an example I can rip off and modify to my needs, I would most appreciate it.
 

Desktop: ASUS Z97-AR | i7-4790K Devil's Canyon | ASUS GTX 980Ti STRIX OC | Corsair 650W TX | Corsair Vengeance - 8 GB 1600 MHz | Samsung Pro 840 - 256GB | SilentiumPC HE1225 | Cooler Master HAF-932 Adv. | Razer Deathstalker | Razer Taipan | SteelSeries DEX | SteelSeries Siberia Elite Black Prism Edition | DXRacer Maximum Series | Bluemic Snowball Aluminium 
Laptop: ASUS Zenbook UX32LN

Camera: Nikon D5300

Link to post
Share on other sites

Is the objective to show the user a specified path used by the program? Like C:\users\[name]\documents\saves then opening the path though the program displays the contents of the folder in Windows Explorer. Is this what you're asking?

 

Wait. Or are you asking for a way to add a item to the right-click menu for an application?

Link to post
Share on other sites

6 minutes ago, Windows7ge said:

Is the objective to show the user a specified path used by the program? Like C:\users\[name]\documents\saves then opening the path though the program displays the contents of the folder in Windows Explorer. Is this what you're asking?

No - this is how it is.
I have program.exe located in D:/Program/.

I want to add context menu option when right clicking on folder that says "Open in Program" - once clicked, it should run D:/Program/program.exe -path path_to_clicked_folder.

Desktop: ASUS Z97-AR | i7-4790K Devil's Canyon | ASUS GTX 980Ti STRIX OC | Corsair 650W TX | Corsair Vengeance - 8 GB 1600 MHz | Samsung Pro 840 - 256GB | SilentiumPC HE1225 | Cooler Master HAF-932 Adv. | Razer Deathstalker | Razer Taipan | SteelSeries DEX | SteelSeries Siberia Elite Black Prism Edition | DXRacer Maximum Series | Bluemic Snowball Aluminium 
Laptop: ASUS Zenbook UX32LN

Camera: Nikon D5300

Link to post
Share on other sites

4 minutes ago, Netheous said:

No - this is how it is.
I have program.exe located in D:/Program/.

I want to add context menu option when right clicking on folder that says "Open in Program" - once clicked, it should run D:/Program/program.exe -path path_to_clicked_folder.

OK I think I get it (If you haven't noticed already I'm not much of a programmer) I know the registry can be edited via CMD so if you're up for figuring out how to edit the registry via CMD and put those commands into a .bat file that should work. Then for your users it'd just be the one click process you're asking for.

Link to post
Share on other sites

Nevermind, got it working - here's how it's done for others who stumble upon this post.
 

@echo off

SET fpath=D:\Program\Program.exe

echo "This is the path %fpath%"

rem add item to folder context menu
@reg add "HKCR\Directory\shell\Open with Program"				/t REG_SZ /v "" /d "Open with Program" /f
@reg add "HKCR\Directory\shell\Open with Program\command"		/t REG_SZ /v "" /d "%fpath% "-path" "%%1" /f

pause

 

Desktop: ASUS Z97-AR | i7-4790K Devil's Canyon | ASUS GTX 980Ti STRIX OC | Corsair 650W TX | Corsair Vengeance - 8 GB 1600 MHz | Samsung Pro 840 - 256GB | SilentiumPC HE1225 | Cooler Master HAF-932 Adv. | Razer Deathstalker | Razer Taipan | SteelSeries DEX | SteelSeries Siberia Elite Black Prism Edition | DXRacer Maximum Series | Bluemic Snowball Aluminium 
Laptop: ASUS Zenbook UX32LN

Camera: Nikon D5300

Link to post
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

×