Re: read .reg file
- From: mr_unreliable <kindlyReplyToNewsgroup@xxxxxxxxxxx>
- Date: Wed, 27 Feb 2008 17:07:18 -0500
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)
.
- References:
- read .reg file
- From: Jeroen
- read .reg file
- Prev by Date: Empty the Recycle Bin
- Next by Date: Re: Empty the Recycle Bin
- Previous by thread: read .reg file
- Next by thread: Re: Script for verifying files
- Index(es):
Relevant Pages
|