DVation191
asked on
Editing windows registry with vbscript
I have a very basic vbscript I want to use to edit the windows registry. I have all the edits working except for the REG_BINARY keys. I can't figure out how it works...I never seem to get the results I expect.
Take this key for instance:
Set WshShell = Wscript.CreateObject("Wscr ipt.Shell" )
WshShell.RegWrite "HKCU\Software\RealVNC\Win VNC4\Passw ord", <value>, "REG_BINARY"
I don't understand what I need to put for <value>. The problem is that I know what I want the value to show in the windows registry: 4c,00,6a,85,17,ee,bf,3d
I've tried 4c,00,6a,85,17,ee,bf,3d with and without quotes, 4c006a8517eebf3d with and without quotes, I even tried the binary conversion of that hex and either the value that shows up in the registry is wrong or I get a vbscript error about a type mismatch. Where am I going wrong here?
Take this key for instance:
Set WshShell = Wscript.CreateObject("Wscr
WshShell.RegWrite "HKCU\Software\RealVNC\Win
I don't understand what I need to put for <value>. The problem is that I know what I want the value to show in the windows registry: 4c,00,6a,85,17,ee,bf,3d
I've tried 4c,00,6a,85,17,ee,bf,3d with and without quotes, 4c006a8517eebf3d with and without quotes, I even tried the binary conversion of that hex and either the value that shows up in the registry is wrong or I get a vbscript error about a type mismatch. Where am I going wrong here?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It still needs to be set in as an array if it's binary. That doesnt' change.
Chris
ASKER
No, I haven't tried WMI yet. I suppose I could use that instead. Can I use vbscript and WMI in the same vbs file? Or do I need to change all my other vbscript lines of code to WMI? What are the WMI commands for REG_SV and the other registry data types?
You can use either or, there's no reason you can't use both. All the bits above were VbScript used to access WMI, so there's no reason they shouldn't work in the same file.
String Values are:
REG_SZ: objRegistry.SetStringValue
REG_DWORD: objRegistry.SetDWORDValue
REG_BINARY: objRegistry.SetBinaryValue
REG_MULTI_SZ: objRegistry.SetMultiString
REG_EXPAND_SZ: objRegistry.SetExpandedStr
I think that covers them all.
Chris
ASKER
Took me a while to iron out some of the details, but in the end I have a script that does what I need it to. Thanks.
Glad I could help :)
Chris
ASKER