We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Registry adds in vbs??

maximaal asked
Medium Priority
Last Modified: 2008-01-09
I have a .reg file, working fine. But now i want to add the registry add to the login script (vbs)
Most of it is no problem. But the Hexadecimal is drivin me insane.
How can i add this to my login script, on a easy way??



Watch Question


this is one of the things i tried:

WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState\Settings","0c,00,02,00,1b,01,e7,77,60,00,00,00","REG_BINARY"
I think WSH RegWrite will write at most one DWORD (= FOUR bytes of binary data) to a REG_BINARY value. Larger values are not supported with this method.

I usually just create the .REG file and shell out regedit /s myfile.reg to add the registry edits.

if you want to get real fancy you can try WMI (with XP and Win2K)

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputer & "\root\default:StdRegProv")
sKeyPath = "Software\MicrosoftWindows\CurrentVersion\Explorer\CabinetState\"
sValueName = "Settings"
oReg.SetBinaryValue HKCU, sKeyPath, sValueName, aValueData

But I'm not the best with WMI stuff :-)


it really looks fancy, but i just want to add the registry add to my current script.


So as I've said, I would just do something like:

Set WSHShell.Run ("%windir%\regedit.exe /s myfile.reg")

If you want the registry edit itself to be part of the script, just write it out to the temp directory using the FileSystem Object first and then run the WSHSell.Run ...

Hope this helps,

Brad D.


Is there no way to include this registry add without redirecting to the reg file?
Sure, there are lots of ways, all depending upon your definition of "easy way"

Since your data appers larger then four bytes however, I don't think that RegWrite will do the trick for you, so some of your options are:

1) Use WMI (some example code is at http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/registry/)

2) Write out to a .reg file and shell it out using regedit.exe /s

3) Shell out the approperite entries to reg.exe (Win2K /XP)

4) Use a 3rd Party RegWriting ActiveX Application, somethink like Registry Pro http://www.downloadjunction.com/product/software/21609/

5) Write your own ActiveX Control that writes out to the registry. There are lots of samples on making ActiveX controls
and reading/writing the registry in VB itself.

..That's all I can think of a the momemt, but I'm sure there are other ways as well.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


ok, tnx.
I see them as a 2nd choice.
I cant understand why there is no way to include hexadecimal into vbs
Neither can I,  for some reason they imposed a 4 byte limit. I guess it needed to be released on a certain date even if all the features weren't fully implemented?


Is there no trick to fix it?
Not that I know of, perhaps there is (or will be) a new release of VBScript without the limitation.

Wish I could say more
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.