Solved

Adding Registry Key via VBS

Posted on 2004-08-16
1
453 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

776 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