![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Copy a binary registry value to another value. I need to copy the contents of a binary value to another location in the registry. For example: set oShell = CreateObject("Wscript.Shell") Key1 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections\DefaultConnectionSettings" Key2 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections\Connection1" TransferSetting = oShell.RegRead (Key1) oShell.RegWrite Key2,TransferSetting,"REG_BINARY" Everything works until I do the write portion of this script. Than I get type mismatch presumably because the key has been saved as a string instead of as a binary value. I need to copy the binary value to more than one location, and the name of the destintation is not consistant, so other methods like using a reg file are not an option. Anyone have an idea on how to do this? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Copy a binary registry value to another value. WScript.Shell Registry functions are rather limited. The hack used in the past for binary has been to export the key, edit the text file, then re-import. Very messy. ![]() You can do get fairly complete Registry functionality using WMI through VBScript. (WMI is generally pre-installed and running on all Windows PCs since at least WinME. I'm not sure about Win2000. It can be installed on Win98.) The WMI functions are badly designed, and WMI itself is very slow and clunky. But it works. See here for sample code: www.jsware.net/jsware/scripts.php5#wmirclas The download is a VBScript class that's designed to make WMI Registry functions easier. It hides the WMI StdRegProv Registry functions mess inside the class and provides clear, simple functions like GetValue, SetValue, EnumKeys, etc. (If you haven't used classes before.... you can just paste the class at the end of your script -- or load it from an external file and call ExecuteGlobal on it -- and then create an instance of the class as an object.) Quote: > I need to copy the contents of a binary value to another location in the > registry. For example: > > set oShell = CreateObject("Wscript.Shell") > Key1 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet > Settings\Connections\DefaultConnectionSettings" > Key2 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet > Settings\Connections\Connection1" > TransferSetting = oShell.RegRead (Key1) > oShell.RegWrite Key2,TransferSetting,"REG_BINARY" > > Everything works until I do the write portion of this script. Than I get > type mismatch presumably because the key has been saved as a string Quote: > of as a binary value. I need to copy the binary value to more than one > location, and the name of the destintation is not consistant, so other > methods like using a reg file are not an option. Anyone have an idea on Quote: > to do this? |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Copy a binary registry value to another value. All versions of Windows 2000 come with WMI. As I recall, it must be installed on NT. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- "mayayana" <mayaXXyana@xxxxxx> wrote in message news:O$O3k$JLKHA.4516@xxxxxx Quote: > WScript.Shell Registry functions are rather limited. > The hack used in the past for binary has been to > export the key, edit the text file, then re-import. > Very messy. ![]() > > You can do get fairly complete Registry functionality > using WMI through VBScript. (WMI is generally pre-installed > and running on all Windows PCs since at least WinME. > I'm not sure about Win2000. It can be installed on Win98.) > > The WMI functions are badly designed, and WMI itself > is very slow and clunky. But it works. See here for sample > code: > www.jsware.net/jsware/scripts.php5#wmirclas > > The download is a VBScript class that's designed to make > WMI Registry functions easier. It hides the WMI StdRegProv > Registry functions mess inside the class and provides clear, > simple functions like GetValue, SetValue, EnumKeys, etc. > (If you haven't used classes before.... you can just paste the > class at the end of your script -- or load it from an external > file and call ExecuteGlobal on it -- and then create an instance > of the class as an object.) > > Quote: >> I need to copy the contents of a binary value to another location in the >> registry. For example: >> >> set oShell = CreateObject("Wscript.Shell") >> Key1 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet >> Settings\Connections\DefaultConnectionSettings" >> Key2 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet >> Settings\Connections\Connection1" >> TransferSetting = oShell.RegRead (Key1) >> oShell.RegWrite Key2,TransferSetting,"REG_BINARY" >> >> Everything works until I do the write portion of this script. Than I get >> type mismatch presumably because the key has been saved as a string Quote: >> of as a binary value. I need to copy the binary value to more than one >> location, and the name of the destintation is not consistant, so other >> methods like using a reg file are not an option. Anyone have an idea on Quote: >> to do this? > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Copy a binary registry value to another value. Oldguard wrote: Quote: > I need to copy the contents of a binary value to another location in the > registry. Instead of using RegRead/Write, I suggest using wmi's "StdRegProv" class, as follows: Set objRegistry = GetObject("winmgmts:root\default:StdRegProv") From there, you have access to the "GetBinaryValue" and "SetBinaryValue" methods, which might work better for what you want to do. Here is some documentation: http://msdn.microsoft.com/en-us/libr...64(VS.85).aspx Also, there are some example scripts to be found in this ng. Use "advanced group search" and look for "default:StdRegProv" and "GetBinaryValue". cheers, jw ____________________________________________________________ You got questions? WE GOT ANSWERS!!! ..(but, no guarantee the answers will be applicable to the questions) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Adding new String and Binary valules to registry | PowerShell | |||
| how to write/change binary value in registry | VB Script | |||
| 64 bit binary or (-bor operator)? | PowerShell | |||
| How to embed manifest in TCL binary? - mt.exe corrupting my binary | Vista General | |||
| Copy-Item or Copy-ItemProperty and Remote Registry. | PowerShell | |||