Using VBS to manipulate the registry, you typically use the Regread/regwrite/regdelete method, such as:
RegRead:
'Read.vbs (Save the following code as a read.vbs file) DimOperationregistrySetOperationregistry=wscript.createobject ("Wscript.Shell")Dimread_data1,read_data2 read_data1=operationregistry.regread ("hkcr\.xxf\")'reads the default value of the. XXF primary key under the root key HKEY_CLASSES_ROOT, and sends that data to the variable read_data1Read_data2=operationregistry.regread ("Hkcr\.xxf\value")'reads the data from the value key under the primary key and sends the data to the variable READ_DATA2. XXF MsgBox("default="&Read_Data1&"value="&read_data2)'display the data that is read
Regwirte:
'Write.vbsDimOperationregistrySetOperationregistry=wscript.createobject ("Wscript.Shell") Default=operationregistry.regread ("hkcr\")'gets a null value (NULL)Operationregistry.regwrite"hkcr\.xxf\",Default'create a new primary key under the root key HKEY_CLASSES_ROOT. XXF, and set its default value to nullOperationregistry.regwrite"hkcr\.xxf\","Xxffile"'under the root key HKEY_CLASSES_ROOT, create a new primary key. XXF, and set its default value? quot;xxffile "Operationregistry.regwrite"hkcr\.xxf\value1","string"'under Primary key. XXF creates a new string key value value1, and resets its initial value to "string"Operationregistry.regwrite"hkcr\.xxf\value2",1,"REG_DWORD"'under primary key. XXF Create a new REG_DWORD type key value value2, and set its initial value to 1Operationregistry.regwrite"Hkcr\.xxf\value3", 0XFF,"REG_Binary"'under primary key. XXF Create a new binary type key value Value3, and set its initial value to be 16 in the FF
RegDelete:
'Delete.vbsDimOperationregistrySetOperationregistry=wscript.createobject ("Wscript.Shell") Operationregistry.regread ("Hkcr\.xxf\value")'Remove the value key under the. XXF PRIMARY KeyOperationregistry.regread ("hkcr\.xxf\")'Delete the. XXF primary key under the root key HKEY_CLASSES_ROOT
However, if you want to insert hexadecimal data there is a problem, such as writing the following registry key value, if you use RegWrite, the "Type mismatch" error is reported, because Regwirte only supports a value when writing a hexadecimal value, and does not support arrays:
Windows Registry Editor Version 5.00[hkey_current_user\software\microsoft\windows\currentversion\internet Settings\ Zones\3] "{aeba21fa-782a-4a90-978d-b72164c80120}" =hex:1a,37,61,59,23,52,35,0c,7a,5f,20, 17,2f,1e,1a,19,0e, 2b,01,73,13,37,13,12,14,1a,15,2a,4e,2c,08,0d,20,1b,28,18,
Using the RegWrite method
Dim operationregistry Set operationregistry=wscript.createobject ("Wscript.Shell") Operationregistry.regwrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\ 3 "," 0xff,0x11 "," REG_Binary "
The error is as follows:
Script---------------------------Windows script Host---------------------------: C:\Work\Documents\BOC\BOC. Bancslink\vbs\ie_config\ie_forie-copy. VBS Line: 3 character: 1 Error: Type mismatch code: 800a000d Source: Microsoft VBScript Run-time error---------------------------OK ---------------------------
Workaround:
&h80000001strComputer = "." Set Objregistry = GetObject _ Split ("1a,37,61,59,23,52,35,0c,7a,5f,20,17,2f,1e,1a,19,0e,2b, 01,73,13,37,13,12,14,1a,15,39,4e,2c,08,0d,20,1b,28,18,36,32 ",", ")for i = 0 to UBound (arrvalues): arrvalues (i) = CByte ("&h" & Arrvalues (i)): Nexterrreturn = Objregistry.setbinaryvalue _ (HKEY_CURRENT_USER, StrKeyPath, strValueName, arrvalues)
Reference:
Http://www.cnblogs.com/heimirror/archive/2008/06/25/1229483.html
Https://msdn.microsoft.com/de-de/library/aa393286%28v=vs.85%29.aspx
Http://stackoverflow.com/questions/26967459/convert-hex-string-into-array-and-write-it-to-registry-vbscript
VBS Operation Registry Hex