Technical support and scripting issues
Moderators: JRL, Dorian (MJT support)
-
Me_again
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Post
by Me_again » Sat Dec 02, 2006 1:42 am
On an unattended W2K PC a compiled macro program runs ea 15 mins to check that one, and only one, ftp process is running. I can't get it to fail when testing it, but in use it sometimes fails with this error:
Missing SWbemObject:-2147271406 Line 9 Col 4 Ignore Abort
I believe this must be WMI related. Am I doing something wrong, can I set some error flag to automatically abort on this error?
Code: Select all
Let>APP_TITLE=RealWatch
VBSTART
'Kills a process given its process name
Sub killProcess(pgm)
set wmi = getobject("winmgmts:")
sQuery = "select * from win32_process " & "where name='" & pgm & "'"
set processes = wmi.execquery(sQuery)
for each process in processes
process.terminate
next
End Sub
'returns the number of copies of ProcessName that are running
'will return 0 if ProcessName is not running
Function IsProcessRunning(ProcessName)
Set oWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = oWMIService.ExecQuery ("Select Name from Win32_Process where Name='" & ProcessName & "'")
IsProcessRunning = colProcessList.count
End Function
VBEND
Label>begin
VBEval>IsProcessRunning("ftpprocess"),numrtftp
If>numrtftp=1,finish
If>numrtftp=0,startit
If>numrtftp>1,killit
Label>startit
Run Program>c:\mydir\ftpprocess.exe
GoTo>finish
Label>killit
VBRun>Killprocess,ftpprocess
Wait>2
GoTo>begin
Label>finish
-
JRL
- Automation Wizard
- Posts: 3532
- Joined: Mon Jan 10, 2005 6:22 pm
- Location: Iowa
Post
by JRL » Sat Dec 02, 2006 3:31 pm
Me_again,
Could be I'm missing something but....
I don't have any way to debug your code and even if I did it would probably work for me as well as it works for you. However, it seems to me you've answered your own question.
Can I set some error flag to automatically abort on this error?
Why not create a second executable that sits and waits for the error window? When the error pops up take the appropriate steps to close the error and realwatch, maybe even write a log file, start realwatch running again, then go back to waiting for the error.
Just a thought,
Dick
-
Me_again
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Post
by Me_again » Sat Dec 02, 2006 3:54 pm
Hmmm, that's an idea. Rather than have a watchdog watching the watchdog, I could look for that window at the start of the macro so if a run errored out, at least the next run would clean it up.
-
JRL
- Automation Wizard
- Posts: 3532
- Joined: Mon Jan 10, 2005 6:22 pm
- Location: Iowa
Post
by JRL » Sat Dec 02, 2006 4:15 pm
Or, use Onevent> to look for the error window if its name is unique.
OnEvent>WINDOW_OPEN,Error*,2,FixThisMess
SRT>FixThisMess
//Close error window
//write log
//set flag to let the main program know it has to restart
//Or
//Write a batch file that restarts the executable after a
//suitable timeout (you can use the DOS choice command to timeout a batch
//file ... choice /C:~ /T:~,15 will wait 15 seconds before proceeding
//through the rest of the batch file. you can wait up to 99 seconds)
//Run the batch file making sure that RP_WAIT=0
//Exit the executable
//At its beginning, the executable also needs to look for the existence
//of the batch file and delete it f it exists.
END>FixThisMess