Solved

Adding Registry Key via VBS

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
copyEvens challenge 6 63
mergeTwo  challenge 13 72
allStar challenge 1 43
how to update exe applicatio from internet ? 6 41
Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now