Re: read .reg file

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Jeroen wrote:
reading the .reg file is done:

hi Joroen, yes, the reg file is a text file, which you
can read using fso.

but now I'm looking for a way to recognize patterns, for example: "FontSmoothingOrientation"=dword:00000001 (recognize DWORD values)
"SCRNSAVE.EXE"="C:\\WINDOWS\\System32\\logon.scr" (recognize backslashes)
"UserPreferencesMask"=hex:9e,3e,05,80 (recognize hex values)

As to scanning the reg file for content, I would recommend
using the vbScript "InStr" function. That is, read your
reg file a line-at-a-time, and then "parse" each line.

For example, you might first look for an "=" using InStr.

iPos = InStr(thisLine, "=")

That will give you the position of the "=" in the line,
if any. You can use that to split the line into a
"left portion" (key or subkey) and a "right portion"
(value).

sSubKey = Left(thisLine, iPos - 1)
sValue = Right(thisLine, Len(thisLine) - iPos - 1)

Or, alternatively you could use the "Split" function to
split the line.

Finally, you could use "InStr" again to determine how the
value is specified.

iPos = InStr(sValue, "dword:") ' non-zero result implies dword
iPos = InStr(sValue, "hex:") ' non-zero result implies hex

Also, a quote (") found to the right of the equals, probably
means that the right-hand-side is to be interpreted as a
string.

On the other hand, rather than use scripting to re-write your
registry, you could make up your own reg file, (perhaps using
parts of the reg file you have on hand), and then just "run"
it, with oShell.run. The "Run" method will pick out the
appropriate app for the file if none is given -- in this case
the regedit utility is the default app for a reg file.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)

.



Relevant Pages

  • Re: Adding regkey
    ... If it doesn't have to be vbscript, there are a couple of ways you can do ... Create a .REG file with the keys values you need then use regedit to ... Use a third-part tool. ... My company has developed a tool called Registry ...
    (microsoft.public.scripting.vbscript)
  • Re: Run command not working right
    ... app appears on the screen. ... > To use the Regedit: Save the REG File to your hard disk. ... I ran the Klez and Yaha tools and no virus was found. ...
    (microsoft.public.windowsxp.general)
  • Re: Utility to convert .Reg file to VBScript
    ... > In our environment, VBScript for regedit is OK, REG files are not allowed ... due to system policy. ... are in the .REG file. ...
    (microsoft.public.win2000.registry)
  • Re: add value
    ... fine was that a vbscript could on write 4 bytes to a reg_binary. ... For some reason VBS defaults to writing ... You can also try to construct a .reg file and merge it, ... but that's a bit awkward. ...
    (microsoft.public.scripting.vbscript)
  • Re: Utility to convert .Reg file to VBScript
    ... > allowed due to system policy. ... > that will convert a .REG file into a VBScript that would make the ... > same changes that are in the .REG file. ... Microsoft MVP Scripting and WMI, ...
    (microsoft.public.win2000.registry)