Subject: GetObject Trap
Posted By: bostek Post Date: 11/19/2004 7:09:36 AM
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
            ComputerName & "\root\default:StdRegProv")

statement somehow traps itself and does not return any value (scrpit stops working - freezes).

There are few computers among 6000 comps in the corp. This is just cut-out of the script which is working fine untill this few computers are on (I think because of platform NT 4 which doesn not support automatition objects).

I'm asking: how to make somekind of thread or timer which runs independent from other script and skips the iteration when automatition object does not respond in timely fashion (let's say 10 sec).

I'm already pinging the computer and that works fine the problem is that I cannot get automatition object


Thanx in advance

Reply By: mmcdonal Reply Date: 11/23/2004 7:37:25 AM
Hi,

   As a test, why not try this:

'====================================
Dim stError

On Error Resume Next
Err.Clear

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

stError = Err
WScript.Echo stError
'=========================================

On my Windows XP machine, I get this error returned:

-2147217375

If the rest of your code has error handling, or is running fine, then you can trap this value and do something like

'=============================
If Err = -2147217375 Then ' or "If Err <> 0 Then"
   Set WshShell = WScript.CreateObject("WScript.Shell")
   WshShell.LogEvent 0, "MyScript.vbs: Error " & stError 'or some message
   WScript.Quit
End If
'=============================

if this value is returned. This posts a message to the Event Logs that tells you the script attempted to run, but this error was returned.

You could then put a routine at the beginning of the script that checks for this event log entry and either does something else or quits before it even gets to this point again.

You could also check the version of the OS in another routine at the beginning of the script and tailor the script for each OS version it detects, but this may cause the same sort of failure as above.









mmcdonal
Reply By: bostek Reply Date: 11/24/2004 1:39:49 AM
the problem is that in runtime script just stops working and does not return any value. To solve the problem I would have to set a timer.

but thanx mmcdonal

regards

Go to topic 22558

Return to index page 707
Return to index page 706
Return to index page 705
Return to index page 704
Return to index page 703
Return to index page 702
Return to index page 701
Return to index page 700
Return to index page 699
Return to index page 698