简体   繁体   English

无法从Windows注册表运行vbs文件

[英]Unable to run vbs file from windows registry

I have a registry key that calls a vbscript file as below.It will be triggered on selecting a Change Cursor option from right click on .cur file 我有一个调用vbscript文件的注册表项,如下所示。右键单击.cur文件选择Change Cursor选项时会触发它

"C:\Program Files\Cursor Manager\CustomCursor.vbs" "%1" 2

Below is the vbs file(CustomCursor.vbs) 下面是vbs文件(CustomCursor.vbs)

Set objArgs = WScript.Arguments ' Create object.
CusorValue=objArgs(1)
Path=objArgs(0)
MsgBox CusorValue
MsgBox Path

But its not working.Its not showing any message 但它不起作用。它没有显示任何消息

Its working when i am calling the script from command prompt like below. 当我从命令提示符调用脚本时,它正在工作 ,如下所示。

"C:\Program Files\Cursor Manager\CustomCursor.vbs" "E:\new\CM v5\cursors new\more\Arrow.cur" 2

If the registry value is batch file its working 如果注册表值是批处理文件,则其工作正常

"C:\Program Files\Cursor Manager\CustomCursor.cmd" "%1" 2

Below is batch file(CustomCursor.cmd) 下面是批处理文件(CustomCursor.cmd)

echo %1
echo %2
pause

But i can use batch file as it will show a command window,as it will show command window while executing script. 但是我可以使用批处理文件,因为它会显示一个命令窗口,因为它会在执行脚本时显示命令窗口。

Please tell me a way to execute the vbs file from registry or atleast a way to run batch file in background. 请告诉我一种从注册表执行vbs文件的方法,或者至少在后台运行批处理文件的方法。

Thank you 谢谢

Change your registry to 将注册表更改为

"%windir%\system32\wscript.exe" "C:\Program Files\Cursor Manager\CustomCursor.vbs" "%1" 2

The problem is that invoking directly the script file makes windows search for the program to execute it and call the asociated executable with the script as argument, but in this process the rest of the arguments are discarded. 问题是直接调用脚本文件会使Windows搜索程序执行它并使用脚本作为参数调用相关的可执行文件,但在此过程中,其余参数将被丢弃。 Call yourself the script host with all the needed arguments. 使用所有需要的参数称自己为脚本宿主。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM