WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sample Code from Users

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Recursive Registry Walker

Keywords: 	 recursive registry walker

Our company uses McAfee virus scan to combat PC viruses. I built a separate checker to grab the information and email our RAS Admin to show that a user has the current McAfee engine, data files and version.

HOWEVER, some of the registry information isn't there on our Win95 pcs. This script goes thru a PC's registry (regardless of OS) and pulls all the info, writing it to a local file.

You'll have to add the email code yourself.

This can be easily modified to search other keys and return other values.

Written using Winbatch 99K on NT4.0


;       first define the keys to lookfor...
;       we want everything on HKEY_LOCAL_MACHINE that has to do with Mcafee...
keys2chk = "SOFTWARE\MCAFEE;SOFTWARE\NETWORK ASSOCIATES"
;       initialize the data var...
ilist = ""
;       loop thru the keys...
for kk = 1 to itemcount(keys2chk, ";")
        thiskey = itemextract(kk, keys2chk, ";")
;       get the subkeys under the main keys...
        key=RegOpenkey(@RegMachine, thiskey)
        subkeys=RegQueryKeys(key)
;       loop thru the subkeys...
        for sk = 1 to itemcount(subkeys, @tab)
                subkey = itemextract(sk, subkeys, @tab)
;               build a string for this particular subkey based on its parent key...
                tskey = strcat(thiskey, "\", subkey)
;               get a list of items under this particular subkey...
                items = RegQueryItem(@REGMACHINE, tskey)
;               concatenate this particular subkey onto the data var...
                ilist = strcat(ilist, @crlf, tskey)
;               loop thru the items on this particular subkey...
                for ii = 1 to itemcount(items, @tab)
                        theitem = itemextract(ii, items, @tab)
;               check first for the values' TYPE...
                        tvalue = RegEntryType(@REGMACHINE, strcat(tskey,"[%theitem%]"))
;               if it's a string value, concatenate it onto the data var, otherwise ignore it...
                        if tvalue == 1 || tvalue == 2 then
                                value = RegQueryValue(@REGMACHINE, strcat(tskey,"[%theitem%]"))
                                if strindexwild(theitem, "sz", 1) > 0 then ilist = strcat(ilist, @crlf, @tab, theitem, " = ", value)
                        endif
                next    ; item
        next    ; subkey
;       close the main key
        RegClosekey(key)
next    ; main key
;       find out the name of this PC...
sysinfo = WinSysInfo( )
computer  = ItemExtract(1, sysinfo, @TAB)
;       find out the PC's operating system...
os = winmetrics(-4)
osname = "Other;Windows;Windows for Workgroups;Win32s;Windows NT;Windows 95/Windows 98"
osver = itemextract(os+1, osname, ";")
;       write the data var to a file...
oh = fileopen("c:\mcreginfo.txt", "write")
filewrite(oh, ilist)
filewrite(oh, @crlf)
filewrite(oh, strcat(computer, @tab, osver))
fileclose(oh)
;       display a message to the user...
Message("Registry Keys", ilist)
;       all doned...
exit


Article ID:   W14710
Filename:   Search through Registry.txt
File Created: 2000:09:22:13:08:36
Last Updated: 2000:09:22:13:08:36