MDT Scripting: Managing Registry Keys

There are times during deployments when you may need to manage the registry. For example, finding out what Internet Explorer version the machine is using. Or also, creating keys to run programs at start-up etc. Fortunately, there is a utility class in the ztiUtility.vbs called the oUtility class that can access pre-written functions to help with these issues.

To begin with, create an MDT Scripting Template (as per previous blogs). Then add the custom code below. The code has clever routines to determine the type of data(eg.REG_SZ, REG_DWORD).

To Read a Registry Key.

Dim sRegValue, sRegKey

sRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Version"

oLogging.CreateEntry "IE Version is " & sRegValue, LogTypeInfo

To Write a Registry Key.

Dim sRegValue, sRegKey, sNewRegValue

sRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\New Program"
sNewRegValue = "C:\Windows\Notepad.exe"

sRegValue=oUtility.regWrite(sregkey, sNewRegValue)

About Andrew Barnes

A Scripting and Deployment Specialist.
This entry was posted in MDT 2010, Scripting and tagged , , . Bookmark the permalink.

4 Responses to MDT Scripting: Managing Registry Keys

  1. Alan says:

    Nice blog entry.
    But how do you delete a reg key, which has curly braces?
    (side note, what do the curly braces mean???)
    e.g. this one

    Windows Registry Editor Version 5.00
    putting this in to a .reg file doesn’t work.
    tried removing the braces,
    or putting =”” at the end,
    no go.


  2. Martony says:

    Hi Andrew,

    Is there a function to delete registry key?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s