Re: Still having great difficulty with error handling
From: David Doumani (ddoumani_at_doumaniweb.com)
Date: 03/27/05
- Next message: David Doumani: "Re: accurate installed software list"
- Previous message: William: "accurate installed software list"
- In reply to: Michael Harris \(MVP\): "Re: Still having great difficulty with error handling"
- Next in thread: Al Dunbar [MS-MVP]: "Re: Still having great difficulty with error handling"
- Reply: Al Dunbar [MS-MVP]: "Re: Still having great difficulty with error handling"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 27 Mar 2005 08:47:07 -0500
Mike,
Thanks for the insight, It runs on a known good machine but when it hits a
machne that is "down" I get the error below - any insight as to that? I put
in the echo statement just to check if it was working; i'll add logic once i
get it to acknowledge a bad machine.
Microsoft VBScript runtime error: Type mismatch: 'errNum'
My new statement looks like this
' Bind to the WMI \root\cimv2
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
errNum = hex(Err.number)
On Error GoTo 0
If errNum = &H800706BA Then <---------- this is the line is complains
about
wscript.echo "'unavailable, move on to next..."
End If
"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:OBKskDpMFHA.3760@TK2MSFTNGP12.phx.gbl...
> David Doumani wrote:
>> I tried the ping routine from Joe and the edits from Keith but I
>> still am having issues;
>>
>> Here is my script again; Basically at the..
>>
>> ' Bind to the WMI \root\cimv2
>
> Dim errNum
> On Error Resume Next
> Set objWMIService = GetObject("winmgmts:\\" & strComputer _
> & "\root\cimv2")"
> errNum = hex(Err.number)
> On Error GoTo 0
> If errNum = &H800706BA Then
> 'unavailable, move on to next...
> End If
>
>>
>> if it returns 0x800706BA (RPC_S_SERVICE_UNAVAILABLE) --> 462
>> (ServerNotFound) then I need it to say strcomputer is unavailable and
>> move onto the next one. Can anyone offer any assistance? This is
>> the last piece to my puzzle.
>>
>> TIA
>> dave
>>
>>
>> *****************************************************************************************
>> 'Computer Role 0 = "Standalone Workstation"
>> 'Computer Role 1 = "Member Workstation"
>> 'Computer Role 2 = "Standalone Server"
>> 'Computer Role 3 = "Member Server"
>> 'Computer Role 4 = "Backup Domain Controller"
>> 'Computer Role 5 = "Primary Domain Controller"
>>
>> 'Set up your constants
>> Const ForReading = 1
>> Const HKEY_LOCAL_MACHINE = &H80000002
>>
>> 'Open the File System Object to Feed the Script
>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> 'This line needs to be customized for the servers.txt localtion text
>> file Set objTextFile = objFSO.OpenTextFile ("c:\scripts\servers.txt",
>> ForReading) '*******************************
>>
>> Process_Machines
>>
>> Sub Process_Machines
>> 'Starts the process reading thru the input file line by line until EOF
>> Do Until objTextFile.AtEndOfStream
>> strComputer = objTextFile.ReadLine
>>
>> Wscript.Echo ""
>> Wscript.Echo "********************** Gathering Data On
>> **********************"
>> Wscript.Echo " Computer Name From TXT File : "& strComputer
>> Wscript.Echo "********************** Gathering Data On
>> **********************"
>>
>> ' Bind to the WMI \root\cimv2
>> Set objWMIService = GetObject("winmgmts:\\" & strComputer &
>> "\root\cimv2")
>> Set colItems = objWMIService.ExecQuery("Select * from
>> Win32_Processor",,48) For Each objItem in colItems
>> Wscript.Echo "System Name: " & objItem.SystemName
>> Wscript.Echo "Processor Name: " & objItem.Name
>> Wscript.Echo "Current Clock Speed: " & objItem.CurrentClockSpeed
>> Wscript.Echo "Max Clock Speed: " & objItem.MaxClockSpeed
>> Next
>>
>> Set colItems = objWMIService.ExecQuery("Select * from
>> Win32_BaseBoard",,48) For Each objItem in colItems
>> Wscript.Echo "Manufacturer: " & objItem.Manufacturer
>> Next
>>
>> Set colItems = objWMIService.ExecQuery("Select * from
>> Win32_ComputerSystemProduct",,48)
>> For Each objItem In colItems
>> Wscript.Echo "Computer Model: " & objitem.Name
>> Next
>>
>> Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
>> For Each objItem in colItems
>> Wscript.Echo "Serial Number: " & objItem.SerialNumber
>> Wscript.Echo "BIOSVersion: " & objItem.SMBIOSBIOSVersion
>> Next
>>
>> Set colItems = objWMIService.ExecQuery("Select * from
>> Win32_ComputerSystem",,48)
>> For Each objItem in colItems
>> Wscript.Echo "Total Physical Memory: " &
>> ObjItem.TotalPhysicalMemory If objItem.DomainRole = 0 Then Role
>> ="Standalone Workstation"
>> If objItem.DomainRole = 1 Then Role ="Member Workstation"
>> If objItem.DomainRole = 2 Then Role ="Standalone Server"
>> If objItem.DomainRole = 3 Then Role ="Member Server"
>> If objItem.DomainRole = 4 Then Role ="Backup Domain Controller"
>> If objItem.DomainRole = 5 Then Role ="Primary Domain Controller"
>> WScript.Echo "Machine Role: " & Role
>> Next
>>
>> Set colItems = objWMIService.ExecQuery("Select * from
>> Win32_OperatingSystem",,48)
>> For Each objItem in colItems
>> Wscript.Echo "Operating System: " & objItem.Caption
>> Wscript.Echo "Service Pack Major: " &
>> objItem.ServicePackMajorVersion Next
>>
>>
>> 'Set colItems = objWMIService.ExecQuery ("SELECT * FROM
>> Win32_QuickFixEngineering")
>> ' For Each objItem in colItems
>> ' If ObjItem.HotFixID = "File 1" Then
>> ' Wscript.Echo "Hot Fix ID: Superceded"
>> ' else
>> ' Wscript.Echo "Hot Fix ID: " & objItem.HotFixID
>> 'End if
>> 'Next
>> 'wscript.Echo "********* END QFE; BEGIN SOFTWARE *********"
>>
>> ' Software Routine;
>> 'Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
>> strComputer & "\root\default:StdRegProv")
>> 'strKeyPathA = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
>> 'objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPathA, arrSubKeysA
>> 'For Each subkey In arrSubKeysA
>> ' iRC = objReg.GetStringValue(HKEY_LOCAL_MACHINE, strKeyPathA &
>> subkey, "DisplayName", sValue)
>> ' If iRC <> 0 Then
>> ' objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPathA &
>> subkey, "QuietDisplayName", sValue
>> ' End If
>> ' If sValue <> "" Then
>> ' Wscript.Echo sValue
>> ' End If
>> 'Next
>> Loop
>> End Sub
>> objTextFile.Close
>
> --
> Michael Harris
> Microsoft MVP Scripting
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Please ask follow-up questions via the original newsgroup thread.
>
>
>
- Next message: David Doumani: "Re: accurate installed software list"
- Previous message: William: "accurate installed software list"
- In reply to: Michael Harris \(MVP\): "Re: Still having great difficulty with error handling"
- Next in thread: Al Dunbar [MS-MVP]: "Re: Still having great difficulty with error handling"
- Reply: Al Dunbar [MS-MVP]: "Re: Still having great difficulty with error handling"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|