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 coul开发者_如何学God run a BAT file/command with the selected file as argument.
Specifically, I need to do:
pscp -pw password E:\File.txt myname@machine.univ.edu:/home/myname/Files/
on right clicking the file and selecting the menu item "Copy to server" in windows explorer.
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
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\" myname@machine.univ.edu:/home/myname/Files/"
精彩评论