nrage21
nrage21

Reputation: 25

How can I execute my windows batch file from the context menu?

I have a windows batch file that sizes and sort .jpg images. Inside the folder where the images reside, I want to right click on the empty space and via the context menu then run my sizensort.bat file.

I was able to add the key to the registry using info from other post successfully and I can see the Run SizeAndSort option in my context menu, but when I click on my option, the cmd window won't open and run my batch file. I get the msg "This file does not have an app associated with it for performing this action. Please install an app or, if one is already installed, create an association in the Default Apps Settings page."

Can anyone please review this and help me fix my issue? If possible can someone post step by step instructions? Thx in adv.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\Run SizeAndSort]
@="&Run SizeAndSort"

[HKEY_CLASSES_ROOT\Directory\Background\shell\Run SizeAndSort\command]
@=cmd.exe /s /k pushd "%V"&call "C:\mypath\sizensort.bat";

Ok... after reading several more posts and articles I have adjusted the last line as @="cmd.exe /s /k pushd \"%V&call ""C:\mypath\sizensort.bat""; However I still get the same msg and it doesn't open the cmd prompt or run the .bat file... still not sure if the syntax is correct in the %V&call part... also put double quotes on the filepath because one of the folders has spaces... not sure what else to try or do.

Upvotes: 1

Views: 2714

Answers (1)

nrage21
nrage21

Reputation: 25

Ok... took a break came back... and then solved my own issue lol. I actually went directly to the Key and typed in the value below. I think I messed up the initial syntax on the last line. Now I have to figure out how to close the command prompt when the code finish execution.

cmd.exe /s /k pushd "%V"&call "C:\mypath\sizensort.bat"

to close cmd prompt :)

cmd.exe /s /c /k pushd "%V"&call "C:\mypath\sizensort.bat"

Upvotes: 1

Related Questions