Search the Community
Showing results for tags 'regtoau3'.
-
Eg: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Key\#Test] @="Default Value SZ" "REG-SZ"="Data String 1234567890" "REG-BINARY"=hex:37,01,01,01,01,01,01,01,01,01,01,01,01,01,01,21,21,02,10,35,45,\ 41,21,21,05,74,57,40,54,54,16,54,60,49,64,16,08,46,87,40,64,98,47,96,74,64,\ 91,73,81,53,75,82,07,20,15,38,17,32,87,81,30 "REG-NONE"=hex(0):6f,4e,79,b5,cc,8b,50,bb,f4,b7,e2,6d,2e,38,d2,8b,ad,10,0b,03,a6,\ 1b,53,30,6b,b8,8b,92,d6,04,22,c7,55,b9,a5,33,4d,a8,4e,9b,00,00,00,00,00,00,\ 00,00,00,00 "REG-MULTI-SZ"=hex(7):53,00,74,00,72,00,69,00,6e,00,67,00,20,00,6c,00,69,00,6e,00,65,00,\ 20,00,31,00,00,00,53,00,72,00,65,00,69,00,6e,00,67,00,20,00,4c,00,69,00,6e,\ 00,68,00,64,00,66,00,75,00,79,00,20,00,34,00,00,00,00,00 "REG-EXPAND-SZ"=hex(2):25,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,44,00,69,00,72,00,\ 25,00,5c,00,41,00,6c,00,6f,00,68,00,61,00,5c,00,4b,00,61,00,6b,00,61,00,00,\ 00 "REG-DWORD"=dword:99999999 "VarlueNoData"="" [HKEY_CLASSES_ROOT\KEY\#DEFAULT_REGBINARY] @=hex:37,01,01,01,01,01,01,01,01,01,01,01,01,01,01,21,21,02,10,35,45,\ 41,21,21,05,74,57,40,54,54,16,54,60,49,64,16,08,46,87,40,64,98,47,96,74,64,\ 91,73,81,53,75,82,07,20,15,38,17,32,87,81,30 [HKEY_CLASSES_ROOT\KEY\#DEFAULT_REGMULTISZ] @=hex(7):53,00,74,00,72,00,69,00,6e,00,67,00,20,00,6c,00,69,00,6e,00,65,00,\ 20,00,31,00,00,00,53,00,72,00,65,00,69,00,6e,00,67,00,20,00,4c,00,69,00,6e,\ 00,68,00,64,00,66,00,75,00,79,00,20,00,34,00,00,00,00,00 [HKEY_CLASSES_ROOT\KEY\#DEFAULT_REGEXPANDSZ] @=hex(2):25,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,44,00,69,00,72,00,\ 25,00,5c,00,41,00,6c,00,6f,00,68,00,61,00,5c,00,4b,00,61,00,6b,00,61,00,00,\ 00 [HKEY_CLASSES_ROOT\KEY\#DEFAULT_REGNONE] @=hex(0):6f,4e,79,b5,cc,8b,50,bb,f4,b7,e2,6d,2e,38,d2,8b,ad,10,0b,03,a6,\ 1b,53,30,6b,b8,8b,92,d6,04,22,c7,55,b9,a5,33,4d,a8,4e,9b,00,00,00,00,00,00,\ 00,00,00,00 [HKEY_CURRENT_CONFIG\KEY\#DEFAULT_DWORD] @=dword:00000000 "REG-DWORD"=dword:00000000 [-HKEY_CURRENT_USER\KEY\#Delete] [HKEY_CURRENT_CONFIG\KEY\#DeleteValue] ;@=- "FName"=- "LName"=- ;Test Comments! [HKEY_LOCAL_MACHINE\Key\#TestValue] "Serial"="-" @="" RegWrite("HKEY_CURRENT_USER\Key\#Test", "", "REG_SZ", "Default Value SZ") RegWrite("HKEY_CURRENT_USER\Key\#Test", "REG-SZ", "REG_SZ", "Data String 1234567890") RegWrite("HKEY_CURRENT_USER\Key\#Test", "REG-BINARY", "REG_BINARY", Binary("0x37010101010101010101010101010121210210354541212105745740545416546049641608468740649847967464917381537582072015381732878130")) ;RegWrite("HKEY_CURRENT_USER\Key\#Test", "REG-NONE", "REG_NONE", "6f4e79b5cc8b50bbf4b7e26d2e38d28bad100b03a61b53306bb88b92d60422c755b9a5334da84e9b00000000000000000000") RegWrite("HKEY_CURRENT_USER\Key\#Test", "REG-MULTI-SZ", "REG_MULTI_SZ", "String line 1" & @LF & "Sreing Linhdfuy 4") RegWrite("HKEY_CURRENT_USER\Key\#Test", "REG-EXPAND-SZ", "REG_EXPAND_SZ", "%ProgramDir%\Aloha\Kaka") RegWrite("HKEY_CURRENT_USER\Key\#Test", "REG-DWORD", "REG_DWORD", "-1717986919") RegWrite("HKEY_CURRENT_USER\Key\#Test", "VarlueNoData", "REG_SZ", "") RegWrite("HKEY_CLASSES_ROOT\KEY\#DEFAULT_REGBINARY", "", "REG_BINARY", Binary("0x37010101010101010101010101010121210210354541212105745740545416546049641608468740649847967464917381537582072015381732878130")) RegWrite("HKEY_CLASSES_ROOT\KEY\#DEFAULT_REGMULTISZ", "", "REG_MULTI_SZ", "String line 1" & @LF & "Sreing Linhdfuy 4") RegWrite("HKEY_CLASSES_ROOT\KEY\#DEFAULT_REGEXPANDSZ", "", "REG_EXPAND_SZ", "%ProgramDir%\Aloha\Kaka") ;RegWrite("HKEY_CLASSES_ROOT\KEY\#DEFAULT_REGNONE", "", "REG_NONE", "6f4e79b5cc8b50bbf4b7e26d2e38d28bad100b03a61b53306bb88b92d60422c755b9a5334da84e9b00000000000000000000") RegWrite("HKEY_CURRENT_CONFIG\KEY\#DEFAULT_DWORD", "", "REG_DWORD", "0") RegWrite("HKEY_CURRENT_CONFIG\KEY\#DEFAULT_DWORD", "REG-DWORD", "REG_DWORD", "0") RegDelete("HKEY_CURRENT_USER\KEY\#Delete") RegDelete("HKEY_CURRENT_CONFIG\KEY\#DeleteValue", "FName") RegDelete("HKEY_CURRENT_CONFIG\KEY\#DeleteValue", "LName") RegWrite("HKEY_LOCAL_MACHINE\Key\#TestValue", "Serial", "REG_SZ", "-") RegWrite("HKEY_LOCAL_MACHINE\Key\#TestValue", "", "REG_SZ", "") Download: Here or Attach Code: [-] REG to AU3 ;~ _REGtoAU3(@ScriptDir & "\RegTest.reg") ; * -----:| Func _REGtoAU3($sFileIN, $sFileOUT = "", $ShortKeys = 0) If Not FileExists($sFileIN) Then Return SetError(1, 0, 0) If $sFileOUT = "" Or $sFileOUT = Default Or $sFileOUT = -1 Then $sFileOUT = $sFileIN & ".au3" If FileGetSize($sFileIN) = 0 Then Return SetError(1, "source-file is empty.", 0) Local $hFileIN = FileOpen($sFileIN, 0) If $hFileIN = -1 Then Return SetError(2, "Unable to open source-file.", 0) Local $hFileOut = FileOpen($sFileOUT, 2 + 8) If $hFileOut = -1 Then If $hFileIN Then FileClose($hFileIN) Return SetError(3, "Unable to open destinaion-file.", 0) EndIf Local $cLine, $LinesRead = 0, $Step = 0, $EOF = 0, $RegEditV = 0, $Error = 0, $xPos = 0, $ESC = 0, $Write = 0 Local $REG_Delete = 0, $REG_KEY = "", $REG_ValueName = "", $REG_Type = "", $REG_Value = "" While 1 $cLine = _R2A_ReadLineFile($hFileIN, $EOF) $LinesRead = $LinesRead + 1 Select Case $EOF And $cLine = "" If $Step = 1 Then $Write = _R2A_CommandLine($REG_Delete, $REG_KEY, $REG_ValueName, $REG_Type, $REG_Value, $hFileOut) If @error Then Return SetError(4, "Unable to write to Output! ", 0) EndIf ExitLoop Case $cLine = "" Case $RegEditV = 0 If $cLine = "REGEDIT4" Then $RegEditV = 4 If $cLine = "Windows Registry Editor Version 5.00" Then $RegEditV = 5 Case StringLeft($cLine, 1) = "[" And StringRight($cLine, 1) = "]" $REG_ValueName = "" $REG_Type = "" $REG_Value = "" If $ShortKeys Then $cLine = StringReplace($cLine, "[HKEY_LOCAL_MACHINE", "[HKLM") $cLine = StringReplace($cLine, "[HKEY_CLASSES_ROOT", "[HKCR") $cLine = StringReplace($cLine, "[HKEY_CURRENT_USER", "[HKCU") $cLine = StringReplace($cLine, "[HKEY_USERS", "[HKU") $cLine = StringReplace($cLine, "[HKEY_CURRENT_CONFIG", "[HKCC") EndIf $cLine = StringTrimRight(StringTrimLeft($cLine, 1), 1) If $Step = 1 Then If StringInStr($cLine, $REG_KEY) = 0 Then $Write = _R2A_CommandLine($REG_Delete, $REG_KEY, $REG_ValueName, $REG_Type, $REG_Value, $hFileOut) If @error Then Return SetError(4, "Unable to write to Output! ", 0) EndIf EndIf $REG_KEY = $cLine If StringLeft($REG_KEY, 1) = "-" Then $REG_Delete = 1 $REG_KEY = StringTrimLeft($REG_KEY, 1) $Write = _R2A_CommandLine($REG_Delete, $REG_KEY, $REG_ValueName, $REG_Type, $REG_Value, $hFileOut) If @error Then Return SetError(4, "Unable to write to Output! ", 0) $Step = 0 Else $Step = 1 EndIf Case $Step < 1 Case Else $Step = 2 $Error = 0 If StringLeft($cLine, 2) = "@=" Then $REG_ValueName = "@" $cLine = StringTrimLeft($cLine, 2) If $cLine = "-" Then $Error = 1 ElseIf StringLeft($cLine, 1) = '"' Then $xPos = 0 $ESC = 0 $REG_ValueName = "" For $R2A_i = 1 To StringLen($cLine) Local $lBreak = StringMid($cLine, $R2A_i, 1) Select Case $ESC $ESC = 0 $REG_ValueName = $REG_ValueName & $lBreak Case $lBreak = '\' $ESC = 1 Case $lBreak = '"' If $R2A_i > 1 Then $xPos = $R2A_i + 1 ExitLoop EndIf Case Else $REG_ValueName = $REG_ValueName & $lBreak EndSelect Next If StringMid($cLine, $xPos, 1) = "=" Then $cLine = StringTrimLeft($cLine, $xPos) Else $Error = 2 EndIf Else $Error = 3 EndIf If $Error Then ConsoleWrite("REG to AU3 - Warning " & $Error & ": Bad syntax at value-name in line: " & $LinesRead & @CRLF) ContinueLoop EndIf If StringLeft($cLine, 1) = '"' And StringRight($cLine, 1) = '"' Then $REG_Type = "REG_SZ" $xPos = 0 $ESC = 0 $REG_Value = "" For $R2A_i = 1 To StringLen($cLine) Local $lBreak = StringMid($cLine, $R2A_i, 1) Select Case $ESC $ESC = 0 $REG_Value = $REG_Value & $lBreak Case $lBreak = '\' $ESC = 1 Case $lBreak = '"' If $R2A_i > 1 Then $xPos = $R2A_i + 1 ExitLoop EndIf Case Else $REG_Value = $REG_Value & $lBreak EndSelect Next ElseIf StringLeft($cLine, 1) = "-" Then $REG_Delete = 1 Else Local $sType = StringLeft($cLine, StringInStr($cLine, ":")) $cLine = StringTrimLeft($cLine, StringLen($sType)) Select Case $sType = "dword:" $REG_Type = "REG_DWORD" $REG_Value = Dec($cLine) Case $sType = "hex(7):" $REG_Type = "REG_MULTI_SZ" $REG_Value = _R2A_Hex2String($cLine, $RegEditV) Case $sType = "hex(2):" $REG_Type = "REG_EXPAND_SZ" $REG_Value = _R2A_Hex2String($cLine, $RegEditV) Case $sType = "hex(0):" $REG_Type = "REG_NONE" $REG_Value = StringReplace($cLine, ",", "") Case $sType = "hex:" $REG_Type = "REG_BINARY" $REG_Value = StringReplace($cLine, ",", "") Case StringLeft($sType, 3) = "hex" ConsoleWrite("REG to AU3 - Warning: unsupported key-type: " & $sType & " - in line: " & $LinesRead & @CRLF) ContinueLoop Case Else ConsoleWrite("REG to AU3 - Warning: bad syntax at key-type in line: " & $LinesRead & @CRLF) ContinueLoop EndSelect EndIf $Write = _R2A_CommandLine($REG_Delete, $REG_KEY, $REG_ValueName, $REG_Type, $REG_Value, $hFileOut) If @error Then Return SetError(4, "Unable to write to Output! ", 0) EndSelect WEnd If $hFileIN Then FileClose($hFileIN) If $hFileOut Then FileClose($hFileOut) If FileGetSize($sFileOUT) = 0 Then FileDelete($sFileOUT) Sleep(10) Return SetError(0, 0, 1) EndFunc ;==>_REGtoAU3 ; * -----:| Func _R2A_ReadLineFile($hFileIN, ByRef $EOF) Local $cLine = "", $cContinue = 1, $nBreak, $cBreak, $cRead While $cContinue $cContinue = 0 $cRead = "" While 1 $nBreak = FileRead($hFileIN, 1) If @error = -1 Then $EOF = 1 ExitLoop EndIf $cBreak = Asc($nBreak) If $cBreak > 0 And $cBreak < 254 Then $cRead = $cRead & $nBreak If $cBreak = 10 Then ExitLoop WEnd $cRead = StringStripWS($cRead, 3) If StringRight($cRead, 1) = "\" Then $cRead = StringTrimRight($cRead, 1) $cContinue = 1 EndIf $cLine = $cLine & $cRead WEnd Return SetError(0, 0, $cLine) EndFunc ;==>_R2A_ReadLineFile ; * -----:| Func _R2A_CleanString($sVal) $sVal = StringReplace($sVal, '"', '""') $sVal = StringReplace($sVal, @LF, '" & @LF & "') Return SetError(0, 0, $sVal) EndFunc ;==>_R2A_CleanString ; * -----:| Func _R2A_Hex2String($HexIN, $RegEditV) Local $i, $vChar, $StringOUT = "" If $RegEditV <> 4 Then $RegEditV = 5 For $i = 1 To StringLen($HexIN) $vChar = Chr(Dec(StringMid($HexIN, $i, 2))) If $vChar = Chr(0) Then $vChar = @LF $StringOUT = $StringOUT & $vChar If $RegEditV = 5 Then $i = $i + 5 Else $i = $i + 2 EndIf Next While StringRight($StringOUT, 1) = @LF $StringOUT = StringTrimRight($StringOUT, 1) WEnd Return SetError(0, 0, $StringOUT) EndFunc ;==>_R2A_Hex2String ; * -----:| Func _R2A_CommandLine(ByRef $REG_Delete, ByRef $REG_KEY, ByRef $REG_ValueName, ByRef $REG_Type, ByRef $REG_Value, $hFileOut) Local $cCommand If $REG_Delete Then $cCommand = "RegDelete(" & Chr(34) & _R2A_CleanString($REG_KEY) & Chr(34) If $REG_ValueName <> "" Then $cCommand = $cCommand & ", " & Chr(34) & _R2A_CleanString($REG_ValueName) & Chr(34) Else $REG_KEY = "" EndIf $cCommand = $cCommand & ")" $REG_Delete = 0 Else $cCommand = "RegWrite(" & Chr(34) & _R2A_CleanString($REG_KEY) & Chr(34) If $REG_ValueName <> "" Then If $REG_ValueName = "@" Then $REG_ValueName = "" $cCommand = $cCommand & ", " & Chr(34) & _R2A_CleanString($REG_ValueName) & Chr(34) $cCommand = $cCommand & ", " & Chr(34) & $REG_Type & Chr(34) $cCommand = $cCommand & ", " & Chr(34) & _R2A_CleanString($REG_Value) & Chr(34) EndIf $cCommand = $cCommand & ")" EndIf $REG_ValueName = "" $REG_Type = "" $REG_Value = "" Local $Write = _R2A_WriteOutFile($cCommand, $hFileOut) If @error Then Return SetError(1, 0, 0) Return SetError(0, 0, 1) EndFunc ;==>_R2A_CommandLine ; * -----:| Func _R2A_WriteOutFile($vLine, $hFileOut) If StringInStr($vLine, '"REG_NONE",') Then $vLine = ";" & $vLine If StringInStr($vLine, '"REG_BINARY",') Then $vLine = StringReplace($vLine, '"REG_BINARY", "', '"REG_BINARY", Binary("0x') $vLine = StringReplace($vLine, '")', '"))') EndIf If StringInStr($vLine, '"REG_DWORD",') Then $vLine = StringReplace($vLine, '"REG_DWORD", "', '"REG_DWORD", ') $vLine = StringReplace($vLine, '")', ')') EndIf Local $WriteFile = FileWriteLine($hFileOut, $vLine) If $WriteFile = 0 Then Return SetError(1, 0, 0) Return SetError(0, 0, 1) EndFunc ;==>_R2A_WriteOutFile ; * -----:| REGtoAU3.zip
- 10 replies
-
- registry .reg to autoit .au3
- regtoau3
-
(and 1 more)
Tagged with: