如何添加批处理脚本到多台计算机的上下文菜单 [英] How to add batch script to context menu of multiple computers

查看:201
本文介绍了如何添加批处理脚本到多台计算机的上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试设置一个批处理脚本,可以从文件夹中的上下文菜单中运行。批处理脚本的目的是用预定的文件夹结构填充文件夹。

I've been trying to setup a batch script that can be run from the context menu inside a folder. The purpose of the batch script is to populate the folder with a predetermined folder structure.

这需要在多台计算机上复制(Windows 7-10),所以我的想法是有两个批处理文件和一个.reg文件的网络共享。标记为install.cmd的批处理文件之一将将标记为Subfolders.cmd的另一个批处理文件复制到C驱动器上的文件夹中,并运行.reg文件以在上下文菜单中的子文件夹上安装快捷方式。 cmd批处理文件。

This will need to be replicated on multiple computers(Windows 7-10), so my idea was to have a network share with two batch files and one .reg file. One of the batch files labeled "install.cmd" would copy the other batch file labeled "Subfolders.cmd" to a folder on the C drive, and run the .reg file to install a shortcut on the context menu to the "Subfolders.cmd" batch file.

我创建了Subfolders.cmd批处理文件,它工作,但它必须从我想要的文件夹结构我将感谢任何帮助如何创建install.cmd批处理脚本,将在C驱动器上创建一个文件夹,将Subfolders.cmd脚本复制到其中,并运行.reg文件创建

I have created the "Subfolders.cmd" batch file and it works, but it has to be run from inside the folder I want the folder structure setup in. I would appreciate any help on how to create the "install.cmd" batch script that would create a folder on the C drive, copy the "Subfolders.cmd" script into it, and run the .reg file to create the item in the context menu that would allow the "Subfolders.cmd" batch script to be run in selected folder.

我会感谢任何例子和/或更多的建议,请在下列菜单中选择允许Subfolders.cmd批处理脚本在选定文件夹中运行。有效的方式做到这一点。谢谢!

I'd appreciate any examples and/or suggestions of more efficient ways of doing this. Thanks!

更新:根据要求,我发布了在打开的文件夹中生成子文件夹的代码。这很简单。

Update: As requested, I have posted the code that generates the subfolders inside an opened folder. It's pretty simple.

md "Folder1" "Folder1/Sub1A" "Folder1/Sub1B" "Folder2" "Folder2/Sub2A" "Folder2/Sub2B"


推荐答案

此复制。

"\\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"

这篇关于如何添加批处理脚本到多台计算机的上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆