Reading registry values 
Author Message
 Reading registry values

I need help.  I am trying to write a script that goes out
on the local LAN, queries each machine's registry,
retrieves the value of the registry key,
HKLM/Software/Microsoft/InternetExplorer/Version

It is a REG_SZ value

After it reads the value, it writes to a text file the
computer name and the corresponding value.

Any help would be appreciated.



Sun, 17 Oct 2004 06:00:08 GMT  
 Reading registry values

Quote:

> I need help.  I am trying to write a script that goes out
> on the local LAN,

Do you have the computer names in a text file/spread sheet/database, or do you
need to "ask" the network?

In case of the latter, what type of network do you have (NT 4.0 domain/AD/Novell
etc.)?

Quote:
> queries each machine's registry,
> retrieves the value of the registry key,
> HKLM/Software/Microsoft/InternetExplorer/Version

> After it reads the value, it writes to a text file the
> computer name and the corresponding value.

Here is a couple of methods to query registry remotely:

1)
WMI

2)
Parse the output from Reg.exe (from a VBScript).

Reg.exe is a part of the support tools on the Win2K cd and can take a machine
name as an parameter. If you need more flexibility for the connection part, you
can use the free PsExec.exe as a "wrapper" for Reg.exe.

PsExec:
http://www.sysinternals.com/ntw2k/freeware/psexec.shtml

----------------------------------

You should ping the computers before trying to connect to them. You could parse
the output from ping.exe or use a 3rd party component for this.

The free AspPing from http://www.serverobjects.com/ is one that comes to mind.

----------------------------------

The code below is using WMI and AspPing. It is not complete, it is missing the
build of the loop for all computer names (to vague an input from the original
poster)
NB! Some "air" code:

Const OverwriteIfExist = -1
Const FailIfExist      = 0

Const OpenAsASCII   =  0
Const OpenAsUnicode = -1
Const OpenAsDefault    = -2

Set oFSO = CreateObject("Scripting.FileSystemObject")

' Log file
sFile = "c:\ie_versions.txt"

Set fFile = oFSO.CreateTextFile(sFile, _
                                    OverwriteIfExist, OpenAsASCII)

fFile.WriteLine "**** Query for IE versions started " & Now & " ****"
fFile.WriteLine

' Create some kind of loop here for all computers
'For Each oComputer In oComputers

  ' Something like this
  sComputerName = oComputer.Name

  Set oPinger = CreateObject("AspPing.Conn")

  oPinger.RemoteHost = sComputerName
  oPinger.PingCount = 4
  sResponse = oPinger.Ping

  If sResponse <> empty Then
    'Create WBEM Interface to make system Queries
    Set oLoc = CreateObject("WbemScripting.SWbemLocator")

    'Connect to system via WBEM
    Set oSvcs = oLoc.ConnectServer(sComputerName, "Root\Default")

    'Get a class Instance
    Set oObjs = oSvcs.Get("StdRegProv") 'Get a class Instance

    'Define arguments
    HKLM = &h80000002
    sKeyName = "Software\Microsoft\Internet Explorer"
    sValueName = "Version"

    'Get the value
    'reference: GetStringValue Method in Class StdRegProv
    'http://msdn.microsoft.com/library/psdk/wmisdk/regprovref_2kae.htm
    '
    iRC = oObjs.GetStringValue(HKLM, sKeyName, sValueName, sValue)

    'Check for error
    If iRC = 0 Then
      fFile.WriteLine sValue & " " & sComputerName
    Else
      fFile.WriteLine "StdRegProv error, return code=" & iRC _
                      & " for " & sComputerName
    End If
  Else
    fFile.WriteLine "Could not connect to " & sComputerName
  End If
'Next

fFile.WriteLine
fFile.WriteLine "**** Query for IE versions finished " & Now & " ****"

fFile.Close

--
torgeir



Sun, 17 Oct 2004 12:41:42 GMT  
 Reading registry values

Quote:
>-----Original Message-----

>> I need help.  I am trying to write a script that goes
out
>> on the local LAN,

>Do you have the computer names in a text file/spread

sheet/database, or do you
Quote:
>need to "ask" the network?

>In case of the latter, what type of network do you have

(NT 4.0 domain/AD/Novell
Quote:
>etc.)?

>> queries each machine's registry,
>> retrieves the value of the registry key,
>> HKLM/Software/Microsoft/InternetExplorer/Version

>> After it reads the value, it writes to a text file the
>> computer name and the corresponding value.

>Here is a couple of methods to query registry remotely:

>1)
>WMI

>2)
>Parse the output from Reg.exe (from a VBScript).

>Reg.exe is a part of the support tools on the Win2K cd

and can take a machine
Quote:
>name as an parameter. If you need more flexibility for

the connection part, you
Quote:
>can use the free PsExec.exe as a "wrapper" for Reg.exe.

>PsExec:
>http://www.sysinternals.com/ntw2k/freeware/psexec.shtml

>----------------------------------

>You should ping the computers before trying to connect to

them. You could parse
Quote:
>the output from ping.exe or use a 3rd party component for
this.

>The free AspPing from http://www.serverobjects.com/ is

one that comes to mind.
Quote:

>----------------------------------

>The code below is using WMI and AspPing. It is not

complete, it is missing the
Quote:
>build of the loop for all computer names (to vague an

input from the original

- Show quoted text -

Quote:
>poster)
>NB! Some "air" code:

>Const OverwriteIfExist = -1
>Const FailIfExist      = 0

>Const OpenAsASCII   =  0
>Const OpenAsUnicode = -1
>Const OpenAsDefault    = -2

>Set oFSO = CreateObject("Scripting.FileSystemObject")

>' Log file
>sFile = "c:\ie_versions.txt"

>Set fFile = oFSO.CreateTextFile(sFile, _
>                                    OverwriteIfExist,
OpenAsASCII)

>fFile.WriteLine "**** Query for IE versions started " &
Now & " ****"
>fFile.WriteLine

>' Create some kind of loop here for all computers
>'For Each oComputer In oComputers

>  ' Something like this
>  sComputerName = oComputer.Name

>  Set oPinger = CreateObject("AspPing.Conn")

>  oPinger.RemoteHost = sComputerName
>  oPinger.PingCount = 4
>  sResponse = oPinger.Ping

>  If sResponse <> empty Then
>    'Create WBEM Interface to make system Queries
>    Set oLoc = CreateObject("WbemScripting.SWbemLocator")

>    'Connect to system via WBEM
>    Set oSvcs = oLoc.ConnectServer

(sComputerName, "Root\Default")

- Show quoted text -

Quote:

>    'Get a class Instance
>    Set oObjs = oSvcs.Get("StdRegProv") 'Get a class
Instance

>    'Define arguments
>    HKLM = &h80000002
>    sKeyName = "Software\Microsoft\Internet Explorer"
>    sValueName = "Version"

>    'Get the value
>    'reference: GetStringValue Method in Class StdRegProv
>    'http://msdn.microsoft.com/library/psdk/wmisdk/regprov
ref_2kae.htm
>    '
>    iRC = oObjs.GetStringValue(HKLM, sKeyName,
sValueName, sValue)

>    'Check for error
>    If iRC = 0 Then
>      fFile.WriteLine sValue & " " & sComputerName
>    Else
>      fFile.WriteLine "StdRegProv error, return code=" &
iRC _
>                      & " for " & sComputerName
>    End If
>  Else
>    fFile.WriteLine "Could not connect to " &
sComputerName
>  End If
>'Next

>fFile.WriteLine
>fFile.WriteL{ w   L??G? ?G ine "**** Query for IE

versions finished " & Now & " ****"

Quote:

>fFile.Close

>--
>torgeir

>.

I will need to *ask* the network.  We are on a NT 4 domain
structure.  Sorry about the lack of information, and
thanks for the assistance.

--Darin



Sun, 17 Oct 2004 23:36:16 GMT  
 Reading registry values

Quote:

> I will need to *ask* the network.  We are on a NT 4 domain
> structure.

Try to run this (use cscript.exe in a command window!) and see what happens:

' Substitute MyDomain with your domain name
sDomain = "MyDomain"

Set oComputers = GetObject("WinNT://" & sDomain)
oComputers.Filter = Array("computer")

For Each oComputer In oComputers
    WScript.Echo oComputer.Name
Next

--
torgeir



Mon, 18 Oct 2004 08:04:12 GMT  
 Reading registry values

Quote:
>-----Original Message-----
>I will need to *ask* the network.  We are on a NT 4
domain
>structure

Sorry if this shows up twice. The newsserver I am using
looks like having a hickup again :-(

Try to run this (use cscript.exe in a command window!) and
see what happens:

' Substitute MyDomain with your domain name
sDomain = "MyDomain"

Set oComputers = GetObject("WinNT://" & sDomain)
oComputers.Filter = Array("computer")

For Each oComputer In oComputers
    WScript.Echo oComputer.Name
Next

--
torgeir



Mon, 18 Oct 2004 08:20:37 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. How to read registry values?

2. Reading registry values containing a backslash (\)

3. How do i read registry values

4. How can I read registry values?

5. How can I read registry value(s) with vbscript?

6. Reading Registry values remotely

7. Reading Registry Values

8. reading registry values

9. How to read registry values with vb.NET??

10. Reading registry values outside applicaton area?

11. How to read registry value?

12. Reading Registry Values

 

 
Powered by phpBB® Forum Software