views:

1059

answers:

3

A VBScript cannot edit the registry by default on Vista. How do I get elevation (even if the user has to do something when they run the script) so that the script can edit the registry?

The error is:

---------------------------
Windows Script Host
---------------------------
Script: blah blah blah.vbs
Line:   6
Char:   1
Error:  Permission denied
Code:   800A0046
Source:     Microsoft VBScript runtime error

---------------------------
OK   
---------------------------
A: 

To make it work with native VBScript, you will most likely need a code signing certificate and sign your script with that. More info is in that thread at tek-tips.com.

You could try to write the intended changes to a .reg file and call regedit.exe with that. Maybe this triggers UAC. Did not tried that, though. I have no Vista around right now. :-)

Tomalak
+1  A: 

My understanding was that you could edit HKCU as a normal user, but the others were restricted. I could be wrong. Regardless, there are a couple of example here to do what you want to do.

tloach
This worked great. I used the first method, one caveat is it changes the working directory of the script.
Nick
Also, I was poking around in HKLM so that's probably why I needed elevation.
Nick
A: 

Windows XP had the capability to "Run As..." when you right-clicked a program (like the shortcut to the command line). Doesn't Vista have something like this, "Run as Administrator" or something.

Do this on the command line then have them run the script from the command line?

pfunk