Prev: Write a BynaryStream to clipboard
Next: Sending a Fax
From: .frankie on 13 Feb 2005 03:35 Can you help me writing following value into registry key below "AppSettings"=hex:00,01,00,00 there is no problem to write REG_SZ using this line WshShell.RegWrite "HKCU\Software\Microsoft\Office\AppSettings", "http://x.y.com/...", "REG_SZ" but i dont know how to use Reg.Write to write reg_binary value. I tried these WshShell.RegWrite "HKCU\Software\Microsoft\Office\AppSettings", "hex:00,01,00,00", "REG_BINARY" WshShell.RegWrite "HKCU\Software\Microsoft\Office\AppSettings", "00,01,00,00", "REG_BINARY" - type mismatch error it is possible to write decimal number converted from hex. value but there is problem in format, zero position is complicated to achieve in correct order WshShell.RegWrite "HKCU\Software\Microsoft\Office\AppSettings", "65536", "REG_BINARY" hex:10000 -> dec 65536 -> regvalue 00 00 01 00 hex:100 -> dec 256 -> regvalue 00 01 - still dont know how to write additional 00 00 needed in registry key - how about writing regvalue 02 af 1a 2b 31 b4 c2 ........ thank, you
From: Torgeir Bakken (MVP) on 13 Feb 2005 13:52 ..frankie wrote: > Can you help me writing following value into registry key below > > "AppSettings"=hex:00,01,00,00 > > there is no problem to write REG_SZ using this line > > WshShell.RegWrite "HKCU\Software\Microsoft\Office\AppSettings", > "http://x.y.com/...", "REG_SZ" > > but i dont know how to use Reg.Write to write reg_binary value. I tried > these > > WshShell.RegWrite "HKCU\Software\Microsoft\Office\AppSettings", > "hex:00,01,00,00", "REG_BINARY" > WshShell.RegWrite "HKCU\Software\Microsoft\Office\AppSettings", > "00,01,00,00", "REG_BINARY" > - type mismatch error > > it is possible to write decimal number converted from hex. value but there > is problem in format, zero position is complicated to achieve in correct > order > > WshShell.RegWrite "HKCU\Software\Microsoft\Office\AppSettings", "65536", > "REG_BINARY" > > hex:10000 -> dec 65536 -> regvalue 00 00 01 00 > hex:100 -> dec 256 -> regvalue 00 01 > - still dont know how to write additional 00 00 needed in registry key You will need to convert the data using CLng. CLng (long) will set four bytes, CInt (default) two bytes and CByte (one byte) in the registry with REG_BINARY. This should work: Set oShell = CreateObject("WScript.Shell") sRegValue = "HKLM\Software\ACME\Test" oShell.RegWrite sRegValue, CLng(&H00000100), "REG_BINARY" > - how about writing regvalue 02 af 1a 2b 31 b4 c2 ........ RegWrite will write at most one DWORD to a REG_BINARY value. Larger values are not supported with this method. You can use WMI to do this though: SetBinaryValue Method of the StdRegProv Class http://msdn.microsoft.com/library/en-us/wmisdk/wmi/setbinaryvalue_method_in_class_stdregprov.asp -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/scriptcenter/default.mspx
From: .frankie on 13 Feb 2005 14:43 Thanks for solving my problem. This is exactly what I needed. "Torgeir Bakken (MVP)" <Torgeir.Bakken-spam(a)hydro.com> wrote in message news:upp9W1fEFHA.3780(a)TK2MSFTNGP09.phx.gbl... > .frankie wrote: > >> Can you help me writing following value into registry key below >> >> "AppSettings"=hex:00,01,00,00 >> >> there is no problem to write REG_SZ using this line >> >> WshShell.RegWrite "HKCU\Software\Microsoft\Office\AppSettings", >> "http://x.y.com/...", "REG_SZ" >> >> but i dont know how to use Reg.Write to write reg_binary value. I tried >> these >> >> WshShell.RegWrite "HKCU\Software\Microsoft\Office\AppSettings", >> "hex:00,01,00,00", "REG_BINARY" >> WshShell.RegWrite "HKCU\Software\Microsoft\Office\AppSettings", >> "00,01,00,00", "REG_BINARY" >> - type mismatch error >> >> it is possible to write decimal number converted from hex. value but >> there is problem in format, zero position is complicated to achieve in >> correct order >> >> WshShell.RegWrite "HKCU\Software\Microsoft\Office\AppSettings", "65536", >> "REG_BINARY" >> >> hex:10000 -> dec 65536 -> regvalue 00 00 01 00 >> hex:100 -> dec 256 -> regvalue 00 01 >> - still dont know how to write additional 00 00 needed in registry key > > You will need to convert the data using CLng. CLng (long) will set > four bytes, CInt (default) two bytes and CByte (one byte) in the > registry with REG_BINARY. This should work: > > Set oShell = CreateObject("WScript.Shell") > sRegValue = "HKLM\Software\ACME\Test" > oShell.RegWrite sRegValue, CLng(&H00000100), "REG_BINARY" > > >> - how about writing regvalue 02 af 1a 2b 31 b4 c2 ........ > > RegWrite will write at most one DWORD to a REG_BINARY value. Larger > values are not supported with this method. > > You can use WMI to do this though: > > SetBinaryValue Method of the StdRegProv Class > http://msdn.microsoft.com/library/en-us/wmisdk/wmi/setbinaryvalue_method_in_class_stdregprov.asp > > > > -- > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway > Administration scripting examples and an ONLINE version of > the 1328 page Scripting Guide: > http://www.microsoft.com/technet/scriptcenter/default.mspx
|
Pages: 1 Prev: Write a BynaryStream to clipboard Next: Sending a Fax |