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.
This topic is 11 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
Incroyable HULK
Posts: 1
Last visit: Tue May 15, 2007 12:15 pm

Cannot apply change to registry

Post by Incroyable HULK »

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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Cannot apply change to registry

Post by jvierra »

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
Last visit: Fri Jun 22, 2012 7:17 am

Cannot apply change to registry

Post by rs6000101 »

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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Cannot apply change to registry

Post by jvierra »

Hah! I haven't heard mention of an RS6000 for a decade. Good box.
This topic is 11 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked