How can I check for the presence of a registry entry on remote computers in
my domain?

Any code example?

Thank you!

theo

Re: check for presence of a registry key on remote computers by Torgeir

Torgeir
Mon Mar 01 13:28:51 CST 2004

Theo Welles wrote:

> How can I check for the presence of a registry entry on remote computers in
> my domain?
>
> Any code example?

Hi

Here is a WMI example:

Const HKLM = &H80000002

sComputer = "name or IP address" ' use "." for local computer

Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& sComputer & "\root\default:StdRegProv")

sKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\KB828028"
sValueName = "Installed"
iRC = oReg.GetDWORDValue(HKLM, sKeyPath, sValueName, sValue)

If iRC = 0 Then
If sValue = 1 Then
WScript.Echo "MS04-007 (KB828028) is installed"
Else
WScript.Echo "MS04-007 (KB828028) is not installed"
End If
Else
WScript.Echo "MS04-007 (KB828028) is not installed"
End If



You should check if the remote computer is online before connecting, and
also error handle the WMI connection, take a look here for an example:

http://groups.google.com/groups?selm=3FFF09CA.D7D4888A%40hydro.com


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Re: check for presence of a registry key on remote computers by Robert

Robert
Mon Mar 01 13:28:57 CST 2004


Enumerate Registry Values and Types

Description
Uses WMI to list all the registry values and their types under
HKLM\SYSTEM\CurrentControlSet\Control\Lsa.

Script Code

const HKEY_LOCAL_MACHINE = &H80000002
const REG_SZ = 1
const REG_EXPAND_SZ = 2
const REG_BINARY = 3
const REG_DWORD = 4
const REG_MULTI_SZ = 7

strComputer = "."
Set StdOut = WScript.StdOut

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

strKeyPath = "SYSTEM\CurrentControlSet\Control\Lsa"

oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath,_
arrValueNames, arrValueTypes

For i=0 To UBound(arrValueNames)
StdOut.WriteLine "Value Name: " & arrValueNames(i)

Select Case arrValueTypes(i)
Case REG_SZ
StdOut.WriteLine "Data Type: String"
StdOut.WriteBlankLines(1)
Case REG_EXPAND_SZ
StdOut.WriteLine "Data Type: Expanded String"
StdOut.WriteBlankLines(1)
Case REG_BINARY
StdOut.WriteLine "Data Type: Binary"
StdOut.WriteBlankLines(1)
Case REG_DWORD
StdOut.WriteLine "Data Type: DWORD"
StdOut.WriteBlankLines(1)
Case REG_MULTI_SZ
StdOut.WriteLine "Data Type: Multi String"
StdOut.WriteBlankLines(1)
End Select
Next
-- Robert CohenA legend in his own mind--"Theo Welles"
<theo_welles@yahoo.com> wrote in message
news:e8YzVI8$DHA.2180@TK2MSFTNGP09.phx.gbl...
> How can I check for the presence of a registry entry on remote computers
in
> my domain?
>
> Any code example?
>
> Thank you!
>
> theo
>
>



Re: check for presence of a registry key on remote computers by Theo

Theo
Mon Mar 01 13:53:24 CST 2004

Thank you!

What if I simply want to verify if a key exists, without retrieving its
value(s)?

Which is , referring to your example. what if i just want to check if
SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\KB828028 exists?

Thank you!

theo

"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in message
news:40438EF3.9E0A573B@hydro.com...
> Theo Welles wrote:
>
> > How can I check for the presence of a registry entry on remote computers
in
> > my domain?
> >
> > Any code example?
>
> Hi
>
> Here is a WMI example:
>
> Const HKLM = &H80000002
>
> sComputer = "name or IP address" ' use "." for local computer
>
> Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
> & sComputer & "\root\default:StdRegProv")
>
> sKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\KB828028"
> sValueName = "Installed"
> iRC = oReg.GetDWORDValue(HKLM, sKeyPath, sValueName, sValue)
>
> If iRC = 0 Then
> If sValue = 1 Then
> WScript.Echo "MS04-007 (KB828028) is installed"
> Else
> WScript.Echo "MS04-007 (KB828028) is not installed"
> End If
> Else
> WScript.Echo "MS04-007 (KB828028) is not installed"
> End If
>
>
>
> You should check if the remote computer is online before connecting, and
> also error handle the WMI connection, take a look here for an example:
>
> http://groups.google.com/groups?selm=3FFF09CA.D7D4888A%40hydro.com
>
>
> --
> torgeir
> Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of the 1328 page
> Scripting Guide: http://www.microsoft.com/technet/scriptcenter
>
>



Re: check for presence of a registry key on remote computers by Torgeir

Torgeir
Mon Mar 01 14:00:58 CST 2004

Theo Welles wrote:

> Thank you!
>
> What if I simply want to verify if a key exists, without retrieving its
> value(s)?
>
> Which is , referring to your example. what if i just want to check if
> SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\KB828028 exists?

Hi

See the function RegKeyExists in this post for an example on this:

http://groups.google.com/groups?selm=4027FB99.5DFF5864%40hydro.com


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter