Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Need to force a Timeout

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,59640
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Need to force a Timeout
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Need to force a Timeout - 4/30/2008 2:58:12 AM   
  cshiers

 

Posts: 24
Score: 0
Joined: 4/28/2005
From:
Status: offline
Hey, I am writing a script to connect to several computers to collect information through WMI. I am finding that certain computer in the list are cause the script to hang when trying to connect to it. Is there a way to force a timeout to occur on the get opject function. Or Atleast get it to skip a line of code after a certain amount of time?

The line it is getting stuck on is:

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & objComp & "\root\cimv2")
 
 
Post #: 1
 
 RE: Need to force a Timeout - 4/30/2008 3:00:40 AM   
  cshiers

 

Posts: 24
Score: 0
Joined: 4/28/2005
From:
Status: offline
Or is there a way I can run a check against the remote computer first to ensure I can connect to it?

(in reply to cshiers)
 
 
Post #: 2
 
 RE: Need to force a Timeout - 4/30/2008 3:05:55 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Search the forum for Ping Test.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to cshiers)
 
 
Post #: 3
 
 RE: Need to force a Timeout - 4/30/2008 3:19:53 AM   
  dm_4ever


Posts: 2220
Score: 32
Joined: 6/29/2006
From: Orange County, California
Status: offline
A ping test is a quick way to determine if you should even attempt a WMI connection.

Using SWbemLocator.ConnectServer instead of winmgmts to connect via WMI gives you the ability to specify a timeout...though you only have two options...  forever or 2mins; however if WMI is corrupted then even this won't help.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to cshiers)
 
 
Post #: 4
 
 RE: Need to force a Timeout - 4/30/2008 3:34:08 AM   
  cshiers

 

Posts: 24
Score: 0
Joined: 4/28/2005
From:
Status: offline
I am able to ping the machine, and ping test returns a -1.

DM, here is a bit of a 'tool' question. What would the code be to use SWbemLocator.ConnectServer? I can take a two minute timeout if it works.

(in reply to dm_4ever)
 
 
Post #: 5
 
 RE: Need to force a Timeout - 4/30/2008 3:42:35 AM  1 votes
  dm_4ever


Posts: 2220
Score: 32
Joined: 6/29/2006
From: Orange County, California
Status: offline
http://msdn.microsoft.com/en-us/library/aa393720(VS.85).aspx

      

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to cshiers)
 
 
Post #: 6
 
 RE: Need to force a Timeout - 4/30/2008 5:00:50 AM   
  cshiers

 

Posts: 24
Score: 0
Joined: 4/28/2005
From:
Status: offline
Cheers. Thanks DM. Seems to work now with out hanging.

I've seen this connection string before but didn't realize it was the same as the other way. I will probably use this method from now on.

(in reply to cshiers)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Need to force a Timeout Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts