Re: Help with reading remote registries
From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 01/18/05
- Next message: emebohw2_at_netscape.net: "cdo email results in an email that displays blank sender in outlook"
- Previous message: Matthias Tacke: "Re: Script to format file to character number locations?"
- In reply to: Derek: "Help with reading remote registries"
- Next in thread: Derek: "Re: Help with reading remote registries"
- Reply: Derek: "Re: Help with reading remote registries"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 18 Jan 2005 19:02:20 +0100
Derek wrote:
> Hello,
> I am having trouble with the following script. Could someone please help me
> figure out why I am not able to retrieve the registry key properly from a
> list of computers I am reading from a text file? The script runs fine when
> searching the local computer but will not retrieve the registry key
> remotely? Any help is appreciated, thanks!
>
> Derek
>
> Option Explicit
> On Error Resume Next
Never use a "global" On Error Resume Next during testing and
when having problems!
[snip]
>
> For Each strComputer In arrComputers
> Do While Not objTextFile.AtEndOfStream
You should remove the "Do While" loop as it is not valid any more and
will make the script go into a eternal loop (remove the "On Error
Resume Next" and you will get an error on it).
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> Set objRegistry = GetObject("winmgmts:\\" & _
> strComputer & "\root\default:StdRegProv")
>
> strKeyPath = "SOFTWARE\Veritas\NetBackup\CurrentVersion\"
> strValueName = "version"
> objRegistry.GetStringValue
> HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
>
> If IsNull(strValue) Then
> objfile.Write strComputer & "The registry key does not exist."
> Else
> objfile.Write strComputer,strValue
Again, your "On Error Resume Next" suppresses an error here. The line
above will always fail. Change it to:
objfile.Write strComputer & strValue
> End If
>
>
> objfile.Write VbCrLf & String(80, "-")
> Loop
Remove "Loop".
> Next
-- 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/default.mspx
- Next message: emebohw2_at_netscape.net: "cdo email results in an email that displays blank sender in outlook"
- Previous message: Matthias Tacke: "Re: Script to format file to character number locations?"
- In reply to: Derek: "Help with reading remote registries"
- Next in thread: Derek: "Re: Help with reading remote registries"
- Reply: Derek: "Re: Help with reading remote registries"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|