将上下文菜单添加到 Windows 资源管理器以运行 BAT 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6162415/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding context menu to Windows Explorer to run BAT files
提问by devnull
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.
有什么方法可以向 Windows 资源管理器上下文菜单中添加一个新条目,该条目可以使用所选文件作为参数运行 BAT 文件/命令。
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.
右键单击文件并在 Windows 资源管理器中选择菜单项“复制到服务器”。
采纳答案by Anton Semenov
You need shell extension. CHeck out this for complete guide: http://www.codeproject.com/KB/shell/shellextguideindex.aspx
您需要外壳扩展。查看完整指南: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
并且不要忘记“不要在托管代码中编写进程内 shell 扩展”。详情请见:https: //devblogs.microsoft.com/oldnewthing/20061218-01/?p=28693
回答by V15I0N
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):
将 P:\ath\to\batch.cmd 替换为您的批处理文件,或直接尝试(未经测试):
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\pscp\command]
@="W:\here\it\is\pscp.exe -pw password \"%1\" [email protected]:/home/myname/Files/"