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" sRegValue=oUtility.regread(sregkey) 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)
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
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\Sysprep\Generalize]
“{b636fa27-124f-6436-6a6f-2fe2739a2b89}”=-
putting this in to a .reg file doesn’t work.
tried removing the braces,
or putting =”” at the end,
no go.
LikeLike
Hi Andrew,
Is there a function to delete registry key?
LikeLike
@Martony, There does not appear to be. Very odd! Open the ZTIUtility.vbs file in your scripts folder and take a look through it. In any case, with the new PowerShell capability, I suggest using a PSH script.
LikeLike
Thanx, I’ll have a look at it.
LikeLike