Solved

Adding Registry Key via VBS

Posted on 2004-08-16
1
459 Views
Last Modified: 2008-02-26
I am trying to add a "mydomain" registry key under HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\INTERNET SETTINGS\ZONEMAP\DOMAINS
however the following code does not seem to work. Can  anyone point me in the right direction?

sComputer      = "."
sMethod            = "CreateKey"
hTree            = HKEY_LOCAL_MACHINE
sKey            = "SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\INTERNET SETTINGS\ZONEMAP\DOMAINS\mydomain"


Set oRegistry      = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _
            sComputer & "/root/default:StdRegProv")

Set oMethod      = oRegistry.Methods_(sMethod)
Set oInParam      = oMethod.inParameters.SpawnInstance_()

oInParam.hDefKey       = hTree
oInParam.sSubKeyName      = sKey

Set oOutParam      = oRegistry.ExecMethod_(sMethod, oInParam)
0
Comment
Question by:gbarrientos
1 Comment
 
LVL 6

Accepted Solution

by:
microbolt earned 500 total points
ID: 11814908
Add this line to the top of your VBS script and it should work :)

HKEY_LOCAL_MACHINE = &H80000002
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question