Hi,
I'm trying to write a script that reads .reg file and can compare it to the registry to see if there's a match.
I've got the registry checking part all done in another script, so in this one, I'm looking for reading the .reg file and creating strings that I can use in the regchecking function.
reading the .reg file is done:
Const ForReading = 1, ForWriting = 2, ForAppending = 8
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFile = "U:\tst.reg"
If objFSO.FileExists(strFile) Then
Set objFile = objFSO.GetFile(strFile)
Set filetxt = objFile.OpenasTextStream(ForReading, -2)
Do While Not filetxt.atEndOfStream
line = filetxt.readline
wscript.echo line
Loop
Else
Wscript.Echo "File " & strFile & "doesn't exist"
End If
but now I'm looking for a way to recognize patterns, for example:
Windows Registry Editor Version 5.00 (ignore this sentence)
[HKEY_CURRENT_USER\Control Panel\Desktop] (this is the main key)
"FontSmoothing"="2" (how to get the sub key)
"FontSmoothingOrientation"=dword:00000001 (recognize DWORD values)
"SCRNSAVE.EXE"="C:\\WINDOWS\\System32\\logon.scr" (recognize backslashes)
"UserPreferencesMask"=hex:9e,3e,05,80 (recognize hex values)
"WaitToKillAppTimeout"="20000"
"Wallpaper"=""
"Pattern Upgrade"="TRUE"
[HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics] (recognize next main key, and process subkeys with corresponding main key)
"BorderWidth"="-15"
"CaptionFont"=hex:f5,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,bc,02,00,00,\(recognize multi line strings)
00,00,00,00,00,00,00,00,54,00,61,00,68,00,6f,00,6d,00,61,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"CaptionHeight"="-270"
idea's?
regards,
jeroen
I'm trying to write a script that reads .reg file and can compare it to the registry to see if there's a match.
I've got the registry checking part all done in another script, so in this one, I'm looking for reading the .reg file and creating strings that I can use in the regchecking function.
reading the .reg file is done:
Const ForReading = 1, ForWriting = 2, ForAppending = 8
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFile = "U:\tst.reg"
If objFSO.FileExists(strFile) Then
Set objFile = objFSO.GetFile(strFile)
Set filetxt = objFile.OpenasTextStream(ForReading, -2)
Do While Not filetxt.atEndOfStream
line = filetxt.readline
wscript.echo line
Loop
Else
Wscript.Echo "File " & strFile & "doesn't exist"
End If
but now I'm looking for a way to recognize patterns, for example:
Windows Registry Editor Version 5.00 (ignore this sentence)
[HKEY_CURRENT_USER\Control Panel\Desktop] (this is the main key)
"FontSmoothing"="2" (how to get the sub key)
"FontSmoothingOrientation"=dword:00000001 (recognize DWORD values)
"SCRNSAVE.EXE"="C:\\WINDOWS\\System32\\logon.scr" (recognize backslashes)
"UserPreferencesMask"=hex:9e,3e,05,80 (recognize hex values)
"WaitToKillAppTimeout"="20000"
"Wallpaper"=""
"Pattern Upgrade"="TRUE"
[HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics] (recognize next main key, and process subkeys with corresponding main key)
"BorderWidth"="-15"
"CaptionFont"=hex:f5,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,bc,02,00,00,\(recognize multi line strings)
00,00,00,00,00,00,00,00,54,00,61,00,68,00,6f,00,6d,00,61,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"CaptionHeight"="-270"
idea's?
regards,
jeroen