Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


VBScript On Error Resume Next not working on GetObject WMI

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> VBScript On Error Resume Next not working on GetObject WMI
  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 >>
 VBScript On Error Resume Next not working on GetObject WMI - 12/18/2007 9:28:14 PM   
  humbletech99

 

Posts: 53
Score: 0
Joined: 6/9/2007
Status: offline
I have a script with the following code block:

      
However, when I run it where strServer = nonExistantMachine I get a complete lack of error handling:

      
Why is this occurring if I have told it to continue on error so that I can handle it myself?

_____________________________

value(geeks) > value(mundanes)
 
 
Post #: 1
 
 RE: VBScript On Error Resume Next not working on GetObj... - 12/18/2007 10:20:18 PM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi humbletech99,

as it should work (I just tested with a good and a bad server name), I suspect
that your snippet doesn't reflect your real life conditions/circumstances. Are
you sure, that OERN is in effect when line 290 is executed?

Regards

ehvbs

(in reply to humbletech99)
 
 
Post #: 2
 
 RE: VBScript On Error Resume Next not working on GetObj... - 12/18/2007 10:27:56 PM   
  humbletech99

 

Posts: 53
Score: 0
Joined: 6/9/2007
Status: offline
yes I know this is what's so puzzling, I copied the thing from the script and pasted it into the post above. I just removed a few lines after 290 with <QUIT GRACEFULLY>. I have just checked again that the script I am working on it the one I am running too. That should be the exact code...

_____________________________

value(geeks) > value(mundanes)

(in reply to ehvbs)
 
 
Post #: 3
 
 RE: VBScript On Error Resume Next not working on GetObj... - 12/18/2007 10:36:21 PM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
What happens, if you execute a plain .vbs like from the command line:

Option Explicit
Dim strServer : strServer = "nothere"
Dim objWMIService
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strServer & "\root\CIMV2")
If 0 <> Err.Number Then
  WScript.Echo Err.Number, Err.Description
End If
WScript.Echo "done"

my output is

C:\wis\_vbs\0506\dev\forum
cscript testwmi.vbs
462 Der Remoteservercomputer ist existiert nicht oder ist nicht verfügbar
done

Are you using a .wsf? Perhaps a

<?job error = "true" debug = "true" ?>

is involved.

< Message edited by ehvbs -- 12/18/2007 10:37:54 PM >

(in reply to humbletech99)
 
 
Post #: 4
 
 RE: VBScript On Error Resume Next not working on GetObj... - 12/18/2007 11:11:19 PM   
  humbletech99

 

Posts: 53
Score: 0
Joined: 6/9/2007
Status: offline
yes I'm using wsf but <job> only has an id="name" in it.

I found that that the error handling is working if the server doesn't exist. I was testing this against my workstation from a server, and since I switched off the wmi and then back on this has been happening. I does not happen when strServer is any other machine and if strServer is a fake machine it does not happen either.

Only for this 1 host workstation that I just had to fiddle with. I have no idea why, when I run it from the workstation itself using either localhost, or . or workstationname it works fine...

_____________________________

value(geeks) > value(mundanes)

(in reply to ehvbs)
 
 
Post #: 5
 
 RE: VBScript On Error Resume Next not working on GetObj... - 12/19/2007 3:12:01 AM   
  dm_4ever


Posts: 2724
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
First, any time I make a WMI connection I always test to see if the workstation is valid with a ping test...this will save time.  Second, if your script works locally on the workstation but not remotely...do you have a firewall enabled, have you checked DCOM (if enabled and proper security settings), have you attempted to connect using wbemtest?

_____________________________

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 humbletech99)
 
 
Post #: 6
 
 RE: VBScript On Error Resume Next not working on GetObj... - 12/19/2007 3:38:18 AM   
  humbletech99

 

Posts: 53
Score: 0
Joined: 6/9/2007
Status: offline
wbem test does not connect. In fact the firewall was restarted when I restarted the wmi service...

wbemtest gave me the rpc server is unavailable. I'll have to double check gpo settings on the firewall since it doesn't show remote management in the local firewall.

although I agree with the ping idea, xp sp2 disables ping by default in the firewall and even if it doesn't some people do disable ping. It's better to just do the check, because ping could be blocked but the host and the port required could be up/open.

_____________________________

value(geeks) > value(mundanes)

(in reply to dm_4ever)
 
 
Post #: 7
 
 RE: VBScript On Error Resume Next not working on GetObj... - 12/31/2007 8:46:45 AM   
  jwcmonkey

 

Posts: 1
Score: 0
Joined: 12/31/2007
Status: offline
I am having this same problem. I am trying to get the username from a PC on our domain and when the path doesn't exist the On Error command won't catch the error and the script hangs up. I tried doing a simple ping test but sometimes it will ping but not connect with WMI. Is there anyway to get this On Error to work for WMI or any way to kill WMI if it takes too long? Thank you.

(in reply to humbletech99)
 
 
Post #: 8
 
 RE: VBScript On Error Resume Next not working on GetObj... - 12/31/2007 10:45:08 AM   
  dm_4ever


Posts: 2724
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Post EXACTLY what you've tried.

_____________________________

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 jwcmonkey)
 
 
Post #: 9
 
 RE: VBScript On Error Resume Next not working on GetObj... - 12/31/2007 12:21:49 PM   
  humbletech99

 

Posts: 53
Score: 0
Joined: 6/9/2007
Status: offline
I did that originally, only the <quit gracefully> was omitted and I know this was never run....

Anyway, I'm considering this closed now, it did work for all normal cases and I haven't looked at this in the last 2 weeks, so it doesn't really matter now, I had to let this unusual fringe case go, it's not worth chasing at this point...

_____________________________

value(geeks) > value(mundanes)

(in reply to dm_4ever)
 
 
Post #: 10
 
 
 
  

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 >> VBScript On Error Resume Next not working on GetObject WMI 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