Solved

Adding Registry Key via VBS

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sumDigits  challenge 7 74
control image tags in a string ? 12 110
tvirtualstringtree freeze when load too manny images 10 52
Rubik's Cube Code for Effective Presentation 3 40
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
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…

911 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