smatter
smatter

Reputation: 29178

Adding context menu to Windows Explorer to run BAT files

Is there any way to add a new entry to windows explorer context menu that could run a BAT file/command with the selected file as argument.

Specifically, I need to do:

pscp -pw password E:\File.txt [email protected]:/home/myname/Files/

on right clicking the file and selecting the menu item "Copy to server" in windows explorer.

Upvotes: 4

Views: 5556

Answers (2)

Anton Semenov
Anton Semenov

Reputation: 6347

You need shell extension. CHeck out this for complete guide: http://www.codeproject.com/KB/shell/shellextguideindex.aspx

And dont forget "Do not write in-process shell extensions in managed code". Details here: https://devblogs.microsoft.com/oldnewthing/20061218-01/?p=28693

Upvotes: 3

V15I0N
V15I0N

Reputation: 393

Add some lines to the registry (untested):

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\pscp]
@="Copy To Server"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\pscp\command]
@="%SystemRoot%\\system32\\cmd.exe /c \"P:\\ath\\to\\batch.cmd" \"%1\" %*"

Replace P:\ath\to\batch.cmd with your batch file, or try directly (untested):

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\pscp\command]
@="W:\\here\\it\\is\\pscp.exe -pw password \"%1\" [email protected]:/home/myname/Files/"

Upvotes: 0

Related Questions