Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error handling on remote computer

Status
Not open for further replies.

FloDiggs

MIS
Jan 20, 2007
296
US
I have a script that searches remote computers for PST files via WMI. The problem that I have is that on certain computers it errors, but the error is displayed on the remote computer and the script hangs until someone clicks "OK". Not a big deal, but this script pulls every computer from AD and runs against each one. We'd like to be able to schedule this script to run on the weekends on a regular basis without anyone around to baby sit it. Any suggestions as to how to suppress the error on the remote machine? I'll include the pertinent code for the problem.

Code:
On Error Resume Next
strComputer = "Remote-PC"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_DataFile Where Extension = 'pst'")

For Each objFile in colFiles
    Wscript.Echo objFile.Drive & objFile.Path
    Wscript.Echo objFile.FileName & "." & objFile.Extension
    Wscript.Echo objFile.FileSize
    Wscript.Echo
Next
 
whats the error on the remote machine? seems a strange one to me
 
In all honesty, it looks a bit like a memory error. Regardless, I need to be able to realize the error, skip scanning that PC, record it, and move on to the next one. I'll get more info on the error in a few minutes.
 
the .ExecQuery is a blocked method call so you are in trouble.
if you want to carry on in the same vain then you might consider one script which loops and calls a script which performs the WMI query? that way you can , 1, False on the Run method and your audit process wouldnt halt and wait for one erroring machine?

personally i would aviod the admin workstation type query in this instance and merely update you logonscript to create the audit information.
 
We'd like to keep it out of the log on scripts if possible so that it doesn't slow down log on times. Also, there are plans to use this to search or other files types in the future, such as MDB, MP3, etc. It needs to be able to be run on whim.

This is the error from Windows:

Application popup: Windows - Application Error : The exception unknown software exception (0xc0000409) occurred in the application at location 0x7166710b.

This is the error I get if I run the script locally on that PC with Cscript:

C:\>cscript test.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights res

C:\test.vbs(9, 1) (null): The remote procedure call failed.

 
That is the start of the "For Each" statement in the code I posted above. It actually errors before it gets to that. I added a wscript.echo statement just before that line at one point to try and trouble shoot, and it errored before that as well. The problems seems to be with the WMI query.
 
perhaps if you remove On Error Resume Next you can discover where the errors start
 
If I do put the query into a separate script, won't it still wait for the script to execute before moving on to the next computer in the list?
 
not if the script with the loop which calls the WMI query script has 1, False in the WshShell.Run command

i.e.

'main script

For Each aLine In TextFile
WshShell.Run Chr(34) & "path to WMI script" & Chr(34), 1, False
Next

you will need to consider just how many of these WMI scripts you want allow to kick off on your client machine though.

 
Please pardon my newbieness to VBScript, but what does the 1, False do? Also, how would I limit the number of times it launches at once? Currently, my script pulls all of our computers from Active Directory and then plows through them. I can't launch all of those at once.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top