我的要求非常简单,但我正在努力筛选有关该主题的大量不相关信息。
要求
我的电脑和网络服务器之间已同步文件。基本上,我需要能够右键单击本地文件并将等效的服务器路径(带有一些附加的字符串操作逻辑)复制到剪贴板。
方法
我想我需要做的事情如下:
- 添加一个 Windows 资源管理器上下文菜单选项来执行 WSH 脚本,并将完整文件路径和名称作为参数传递。
- 创建一个 Windows 脚本宿主脚本,该脚本将接受该参数、执行必要的字符串操作并复制到剪贴板。
我可以很好地处理字符串操作(最好是在 VBScript 中)。这是将参数传递给 WSH 脚本的整个过程,我无法真正找到任何相关信息。
或者,我不介意是否使用 PowerShell(如果适用)完成此操作,以便我可以在操作过程中了解更多信息。
非常感谢。
The requirement I've got is pretty straightforward, but I'm struggling sifting through the huge amounts of unrelated information on the subject.
Requirement
I have files synchronised between my PC and my web server. Basically I need to be able to right click on a local file and copy the equivalent server path (with some additional string manipulation logic) to the clipboard.
Approach
I guess what I need done is the following:
- Add a Windows Explorer context menu option to execute a WSH script passing the full file path and name as a parameter.
- Create a Windows Scripting Host script that will accept that paramater, do necessary string manipulation, and copy to clip board.
The string manipulation I can handle fine (preferably in VBScript). It's the whole passing a parameter to the WSH script that I can't really find any info about.
Alternately, I wouldn't mind if this was done with PowerShell (if applicable) so that I can learn a bit more about it while I'm at it.
Many thanks in advance.
发布评论
评论(4)
您可以这样访问 VB 脚本中的参数:
当您注册 shell 上下文菜单命令时,您可以通过注册将路径和文件名作为参数传递:
You can access a parameter in VB script thus:
When you register a shell context menu command, you can pass the path and filename as a parameter by registering:
好的,我修改了一个 VBS 脚本,将其自身注册到资源管理器上下文菜单中,并允许您右键单击文件以将其相应的服务器 URL 复制到剪贴板。
我唯一不喜欢的是它使用 IE 将字符串放入剪贴板的方式,因为它每次都会请求许可。
谁能提出更好的方法?
Ok, I've modified a VBS script by that registers itself in the Explorer context menu and the allows you to right click on a file to copy it's corresponding server URL to the clipboard.
The only thing I don't like is the bit the way it uses IE to put the string in the clipboard since it asks for permission every time.
Can anyone suggest a better approach?
抱歉,它是法语的,但如果您有兴趣,我可以假设某些部分的翻译。我一年前写了一篇名为 Un menu contextuel "Full PowerShell" dans l'explorer de Windows 可以翻译为“Windows 资源管理器中的完整 powershell 上下文菜单”。具体给出的示例是文件的MD5哈希计算。
Sorry it's in french, but I can assume the translation of some parts if you are interested. I wrote a year ago an article called Un menu contextuel "Full PowerShell" dans l'explorer de Windows which can be translated as "a full powershell contextual menu in Windows Explorer". The concrete given sample is the MD5 hash computing of a file.
根本不需要使用任何脚本
设置 key 的默认值
HKEY_CLASSES_ROOT*\shell\复制服务器路径\Command
到:
cmd.exe /c echo "%1"|clip
作业完成...
祝你今天过得愉快
PS 我从 http://www.askvg.com/registry-tweak-to-add-copy-as-path-option-in-files-and-folders-context-menu-in-windows/
No need to use any script at all
set the Default value of key
HKEY_CLASSES_ROOT*\shell\Copy Server Path\Command
to:
cmd.exe /c echo "%1"|clip
Job done...
Have a nice day
PS I got this from http://www.askvg.com/registry-tweak-to-add-copy-as-path-option-in-files-and-folders-context-menu-in-windows/