OnEvent PROCESS_NOTEXISTS

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
[email protected]
Junior Coder
Posts: 25
Joined: Wed Jul 20, 2011 3:07 pm

OnEvent PROCESS_NOTEXISTS

Post by [email protected] » Mon Jul 28, 2014 2:38 am

I am having problems with the OnEvent>PROCESS_NOTEXISTS not firing.
Following is excerpts from my code. CopyFile.exe is a compiled script that starts xcopy.exe and displays a progress bar dialog. All of that works fine. The copy is accomplished and the progress bar dialog closes. The parent dialog indicates that the copy is running. The OnEvent is supposed to change that to "Completed" when the xcopy.exe process drops out, but it never seems to fire.
.
.
.
Let>RP_WAIT=0
Run>%Script_Dir%\CopyFile.exe /From=%BUFrom%\RWDDATA.RBK /To=%BUTo% /PLeft=%DialogLeft% /PTop=%DialogTop%
WaitProcessExists>xcopy.exe
OnEvent>PROCESS_NOTEXISTS,xcopy.exe,,CheckBU

SetDialogProperty>Dialog1,lblEOMR,Visible,True
SetDialogProperty>Dialog1,btnEOMR,Visible,True
SetDialogProperty>Dialog1,cmpHBackup,Caption,Running
SetDialogProperty>Dialog1,cmpHBackup,Visible,True
SetDialogProperty>Dialog1,btnHBackup,Visible,False
.
.
.
SRT>CheckBU
MDL>I'm in CheckBU
ReadIniFile>%SCRIPT_DIR%\CK_CheckPrinting.ini,PROCESS RESULTS,BU_Results,BUR
If>BUR=True
SetDialogProperty>Dialog1,cmpHBackup,Caption,Completed
OnEvent>PROCESS_NOTEXISTS,xcopy.exe,,
Endif
If>BUR=False
SetDialogProperty>Dialog1,cmpHBackup,Caption,Failed
OnEvent>PROCESS_NOTEXISTS,xcopy.exe,,
ASK>The cross machine backup copy failed!%CRLF%Do you want to try again?,ans
If>ans=YES
Goto>RetryBU
Else
Exit>0
Endif
Endif
END>CheckBU

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: OnEvent PROCESS_NOTEXISTS

Post by Marcus Tettmar » Mon Jul 28, 2014 7:43 pm

OnEvent requires a subroutine name. You seem to have some parms missing. Specify a subroutine which should run when the condition is true (the process ceases to exist).
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

[email protected]
Junior Coder
Posts: 25
Joined: Wed Jul 20, 2011 3:07 pm

Re: OnEvent PROCESS_NOTEXISTS

Post by [email protected] » Tue Jul 29, 2014 12:54 am

In the OnEvent activation, I do have the subroutine specified as CheckBU: OnEvent>PROCESS_NOTEXISTS,xcopy.exe,,CheckBU
In the subroutine I deactivate the OnEvent with: OnEvent>PROCESS_NOTEXISTS,xcopy.exe,,
As I understand it, that is the proper approach.
I do not pass the second parameter as it is my understanding that the PROCESS_NOTEXISTS does not use the second parameter.
Am I misunderstanding your response?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: OnEvent PROCESS_NOTEXISTS

Post by Marcus Tettmar » Tue Jul 29, 2014 1:09 am

I don't see the subroutine specified in you original code but I'm viewing on my phone as away so maybe it's just the formatting going wrong, apologies.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: OnEvent PROCESS_NOTEXISTS

Post by JRL » Tue Jul 29, 2014 3:26 pm

@Mick

I took your code and modified it a bit as I didn't have your executable. Just added a line to copy some data from one place to another using xcopy. Also added a message box to monitor what might be happening. Code is

Code: Select all

Let>Msg_xpos=0
Let>Msg_ypos=0

Let>msg_cnt=0

Let>RP_WAIT=0
Run>cmd /c xcopy i:\dick\pvsw\*.* i:\Dick\newhr\ /s /c /y
WaitProcessExists>xcopy.exe
OnEvent>PROCESS_NOTEXISTS,xcopy.exe,,CheckBU

Label>Loop
  Wait>0.01
Goto>Loop

SRT>CheckBU
  Add>msg_cnt,1
  SetControlText>Macro Scheduler Message,TMemo,1,msg_cnt
  OnEvent>PROCESS_NOTEXISTS,xcopy.exe,,
  If>msg_cnt=1
    OnEvent>PROCESS_NOTEXISTS,xcopy.exe,,
    MDL>I'm in CheckBU
    Message>
  EndIf
END>CheckBU
When I run this I find that the OnEvent for PROCESS_NOTEXISTS doesn't get turned off when you use the code line

OnEvent>PROCESS_NOTEXISTS,xcopy.exe,,

Not saying this is correct behavior but there's not much I can do about it other than report it. I suggest you add a little loop in your script that tests the xcopy.exe process using the ProcessExists> function. Something like this:

Code: Select all

Label>CheckProcessExists
ProcessExists>Xcopy.exe,PExRes
If>PExRes=True
  Wait>0.01
  Goto>CheckProcessExists
Else
  GoSub>CheckBU
EndIf 
Simply replace the OnEvent>PROCESS_NOTEXISTS,xcopy.exe,,CheckBU line with this snippet and let us know if things are better.

[email protected]
Junior Coder
Posts: 25
Joined: Wed Jul 20, 2011 3:07 pm

Re: OnEvent PROCESS_NOTEXISTS

Post by [email protected] » Tue Jul 29, 2014 3:59 pm

Thanks JRL
The problem with the monitor approach is that the xcopy and progress bar are in a child process (script) of a parent that fires the child process off and then continues with a series of other functions that are being accomplished. I don't want the user having to wait for the copy of 500MB unnecessarily. When the copy process is completed, I want the parent to indicate that on it's dialog. When the parent reaches the point that the copy must have been completed, I check that it has in fact completed and wait if it hasn't. The function of the OnEvent within the parent process is simple to change the status in the parent dialog.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: OnEvent PROCESS_NOTEXISTS

Post by JRL » Tue Jul 29, 2014 6:17 pm

I've submitted a request to create a method or function to deactivate PROCESS_NOTEXISTS.


In the mean time, here's another possibility.
- Create and run a dynamic script that invokes PROCESS_NOTEXISTS OnEvent.
- When the xcopy ends the dynamic script creates a file then quits running.
- The master script uses a File_Exists OnEvent that jumps to your CheckBU subroutine.
- First lines in the subroutine delete the dynamic script files.

Code: Select all

Let>RP_WAIT=0
Run>%Script_Dir%\CopyFile.exe /From=%BUFrom%\RWDDATA.RBK /To=%BUTo% /PLeft=%DialogLeft% /PTop=%DialogTop%
WaitProcessExists>xcopy.exe
LabelToVar>ProcessExistScript,ProcExistScp
WriteLn>%Temp_Dir%~~WaitingForXcopyComplete~~.scp,wres,ProcExistScp
ExecuteFile>%Temp_Dir%~~WaitingForXcopyComplete~~.scp
OnEvent>File_Exists,%temp_dir%~~XcopyComplete~~,,CheckBU

SetDialogProperty>Dialog1,lblEOMR,Visible,True
SetDialogProperty>Dialog1,btnEOMR,Visible,True
SetDialogProperty>Dialog1,cmpHBackup,Caption,Running
SetDialogProperty>Dialog1,cmpHBackup,Visible,True
SetDialogProperty>Dialog1,btnHBackup,Visible,False
.
.
.
SRT>CheckBU
  DeleteFile>%temp_dir%~~XcopyComplete~~
  DeleteFile>%Temp_Dir%~~WaitingForXcopyComplete~~.scp
  MDL>I'm in CheckBU
  ReadIniFile>%SCRIPT_DIR%\CK_CheckPrinting.ini,PROCESS RESULTS,BU_Results,BUR
  If>BUR=True
    SetDialogProperty>Dialog1,cmpHBackup,Caption,Completed
  Endif
  If>BUR=False
    SetDialogProperty>Dialog1,cmpHBackup,Caption,Failed
    ASK>The cross machine backup copy failed!%CRLF%Do you want to try again?,ans
    If>ans=YES
      Goto>RetryBU
    Else
      Exit>0
    Endif
  Endif
END>CheckBU

/*
ProcessExistScript:
OnEvent>PROCESS_NOTEXISTS,xcopy.exe,,XCopy_Done
Label>Loop
Wait>0.01
Goto>Loop

SRT>XCopy_Done
  WriteLn>%temp_dir%~~XcopyComplete~~,wres,
  Exit>0
END>XCopy_Done
*/

[email protected]
Junior Coder
Posts: 25
Joined: Wed Jul 20, 2011 3:07 pm

Re: OnEvent PROCESS_NOTEXISTS

Post by [email protected] » Tue Jul 29, 2014 6:25 pm

Thank you JRL
I will put your suggestion in place later today and let you know.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts