Access is denied when calling VBScript (.vbs) from the windows context menu
I've written this handy script (for myself, at the moment) that works of a single file. I want to call it from the windows context menu by right clicking the file I want it to process.
Now, i've added a new key under HKEY_CLASSES_ROOT\*\Shell (because I want it to work on *any* file) and have added the following sub-key
(Default) = "%windir%\system32\wscript.exe" "D:\myscripts\myscript.vbs" "%1"
I can now see my new menu item whenever i right-click any file (yay!) but when I click it, I get an error message "Access is denied." - what am i doing wrong or missing?
Now, i've added a new key under HKEY_CLASSES_ROOT\*\Shell (because I want it to work on *any* file) and have added the following sub-key
(Default) = "%windir%\system32\wscript.exe" "D:\myscripts\myscript.vbs" "%1"
I can now see my new menu item whenever i right-click any file (yay!) but when I click it, I get an error message "Access is denied." - what am i doing wrong or missing?
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?If you replace wscript.exe with notepad.exe, do you still get the same error? (I'm wondering if the error occurs while trying to start wscript.exe, or if it actually starts running the script and something the script does causes the error.)
-
Inappropriate?Hi Bruce,
No, I dont get the same error. I also tried changing the whole command to:
cmd.exe /C wscript.exe /nologo "D:\myscripts\myscript.vbs" "%1"
Which does make it work, but they i get a big fat command prompt window flashing when it does. And I'd rather not :)
I’m excited
-
The weird bit is that if I change it to:
"D:\myscripts\myscript.vbs" "%1"
The error message changes to "c:\sample.txt is not a valid win32 application" (assuming that the file I right clicked was c:\sample.txt). Doesnt make sense! -
Inappropriate?next question - if you replace the contents of the .vbs file with something like:
wscript.echo "hello world"
does that work? I'm wondering if it is something inside your .vbs file that is causing the access-denied. -
Inappropriate?Nope, that doesnt work either. After the change, clicking on the menu pops open the "Open with.." dialog box prompting me to select an application to open the file I right-clicked on.
Oh and yes, at this stage - all the VBS script does it pop-up a dialog box showing its argument(s).
I’m thankful
-
Inappropriate?Curious, it seems to be working now. All I did was clear the value and re-create it as:
wscript.exe "D:\myscripts\myscript.vbs" "%1"
How's this different from what I did before!!
Anyway, I happy it works. Thanks for all your help Bruce!
I’m amused
-
Inappropriate?Glad you got it working - it sure was a stumper!
-
Inappropriate?Thanks! Details on how to do this (and also what I was trying to do) are now posted to my blog at:
http://mytechieself.blogspot.com/2008...
Comments and any corrections welcome!
I’m thankful
Loading Profile...



EMPLOYEE