且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何添加批处理脚本到多台计算机的上下文菜单

更新时间:2023-12-06 08:21:46

此复制。

"\\computername\sharename\folder\file.bat"

将运行存储在另一台计算机上的批处理文件。

Will run a batch file stored on another computer.

reg命令

regedit /s "\\computername\sharename\folder\file.reg"

您可以使用旧的映射驱动器以及UNC执行上述操作。

You can do the above with the older mapped drives as well as UNC.

您需要显示您的第二个脚本,以便我们可以看到为什么它需要在文件夹中。

You need to show your second script so we can see why it NEEDS to be in the folder.

EDIT

您需要指定完整路径。

要在注册表命令中使用%V 启动文件夹。所以(让我们摆脱reg文件)(添加你的蝙蝠,而不是回声)

To get the starting folder use %V in the registry command. So (and lets get rid of the reg file) (add your bat instead of echo)

reg add "HKCR\Directory\Background\Shell\Test Command\command" /ve /t REG_EXPAND_SZ /d "cmd /k echo ""%V"""

在您的批处理中,使用%1 获取起始文件夹和波形(%〜1 )删除引号(参见 call /?)。

In your batch use %1 to get the starting folder, and tilde (%~1) to remove quotes (see call /? for documentation). (remember create folders from the lowest level as higer levels get made automatically).

md "%~1\folder1\folder2"