Cannot apply change to registry

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
Incroyable HULK
Posts: 1
Joined: Thu Aug 31, 2006 4:27 am

Cannot apply change to registry

Post by Incroyable HULK » Tue May 15, 2007 12:15 pm

Hello all,
I am trying to modify a registry setting on Windows XP with a VBScript and I am unsuccesfull with the following two methods:

Method 1

Code: Select all

Const HKEY_CURRENT_USER = &H80000001
Set objRegistry = GetObject("winmgmts:.rootdefault:StdRegProv")
strKeyPath = "SoftwareMicrosoftWindowsCurrentVersionInternet SettingsZone1"
strValueName = "1406"
dwValue = 0
objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue


Method 2

Code: Select all

Dim wshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.RegWrite "HKCUSoftwareMicrosoftWindowsCurrentVersionInternet SettingsZone11406", 0, "REG_DWORD"


I don't get any error message but nothing is applied. I had the same issue with another setting I was trying to set on Vista and I ended up calling and external .reg file applied from the VBScript...

Incroyable HULK2007-05-15 19:29:21

User avatar
jvierra
Posts: 13682
Joined: Tue May 22, 2007 9:57 am
Contact:

Cannot apply change to registry

Post by jvierra » Tue May 15, 2007 4:26 pm

It's a restricted key. REG and regedit can access it directly because tehy ask for more privileges whereas WMI, by default, doesn't. You might be able to get around this by asking for more tokens in WMI. I tried it with "security" but I think you also need "registry" privileges.
I tried it like this:
Set objRegistry = GetObject("winmgmts:{(security,backup)}.rootdefault:StdRegProv")
It still won't work so there is still a privilege missing. If you look at the values "permissions" you will see that it is "protected/read" and script usually runs with low privileges.


User avatar
rs6000101
Posts: 6
Joined: Tue Jun 19, 2012 7:54 am

Cannot apply change to registry

Post by rs6000101 » Tue Jun 19, 2012 9:15 am

Here's somthisng that you might want to try as long as yo have local admin privlidges you can make registry changes to a list of of machines I use this simple script i've made changes up to 75 machines at one time with no poblem.

File 1: REG-ADD.cmd.txt (add the registry entry)
File 2: Hostnames.txt (place either IP or machine name both methods works fineuploads/50517/Reg-Add.zip)

if you need further assistance you may reach me at rs6000@linuxwaves.com

User avatar
jvierra
Posts: 13682
Joined: Tue May 22, 2007 9:57 am
Contact:

Cannot apply change to registry

Post by jvierra » Fri Jun 22, 2012 3:13 am

Hah! I haven't heard mention of an RS6000 for a decade. Good box.

Locked