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

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

Below is the vbs file(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)

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.

Thank you

Upvotes: 3

Views: 3898

Answers (1)

MC ND
MC ND

Reputation: 70923

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. Call yourself the script host with all the needed arguments.

Upvotes: 6

Related Questions