Wrox Programmer Forums
|
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 19th, 2004, 08:09 AM
Authorized User
 
Join Date: Jul 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default GetObject Trap

Set oReg=GetObject("winmgmts:{impersonationLevel=imper sonate}!\\" & _
            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
__________________
regards
Reply With Quote
  #2 (permalink)  
Old November 23rd, 2004, 08:37 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   As a test, why not try this:

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

On Error Resume Next
Err.Clear

 Set oReg=GetObject("winmgmts:{impersonationLevel=imper sonate}!\\" & _
            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 With Quote
  #3 (permalink)  
Old November 24th, 2004, 02:39 AM
Authorized User
 
Join Date: Jul 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
GetObject jdhock8865 Visual Basic 2005 Basics 2 November 3rd, 2008 09:29 PM
getobject() failure- recent Loralee Access 2 November 24th, 2006 02:29 PM
getObject() and shell() question using automation juneBugz Access VBA 0 August 29th, 2005 08:46 PM
why GetObject with IIS is not working alyeng2000 ASP.NET 1.x and 2.0 Application Design 0 September 15th, 2004 09:00 AM
UCOMIRunningObjectTable.GetObject wstueve C# 0 December 18th, 2003 11:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.