Need help Waiting

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
rlchase

Need help Waiting

Post by rlchase » Tue Mar 11, 2003 10:15 pm

I have a script that scans CD's for viruses. I have another that scans HD's on remote computers. Then they both are to FTP the log File to my computer. SOmetimes I get the file and other times I don't because the script runs before the scan is over. I have tried this as a test script to determine the cure but to no avail. Part of the script looks like this:

Run Program>C:\Program Files\Common Files\Command Software\csav /all /Delete /list /report=C:\myreport.txt /append C:\a
WaitWindowClosed>C:\Program Files\Common Files\Command Software\csav
Messagemodal>END!!!

The problem is that when the DOS window pops up with C:\Program Files\etc. I assumed that this would wait to execute the next line of script until that window closes, but during testing the messagemodal pops up before it finishes. Is there a WAIT that works in this case? I cannot use Wait>30 because the HD's and CD"S all very on the 34 systems I am responsible for. Anyone with a solution?

Richard Chase
System Administrator Ariesnet
NASA
[email protected]

User avatar
Captive
Macro Veteran
Posts: 213
Joined: Sun Oct 20, 2002 8:37 pm
Location: Colorado, USA

Post by Captive » Wed Mar 12, 2003 2:03 am

There are a few ways to do this, and you're on the right track. The error is probably not how you're approaching the task, for a minor detail based on the timing of the execution.

Some suggestions:
* There is a variable you can change, right before the 'Run program' command. See the help file (under "Run Program") and look at the RP_WAIT variable - it will attempt to wait until the program finishes before it moves on to the next line.
(And this is exactly what you asked for. Hopefully, it will work.)

... some more things to check or to try:
* Putting a short "wait" after the "Run Program>" is a good idea. It gives the program (csav?) a change to initialize and bring up that window before your script actually checks to see if the window is open/closed.
Your 'WaitWindowClose" might be running *before* the window actually exists. Maybe add something like: Wait>2

* There might also be other hidden windows with the same or similar names that open and close. Make sure of the name of the window. Try using a "GetActiveWindow" command just to test.

* The first time I write scripts like this, I will add a bunch of debugging messages using "MessageModal>something here" ... sometimes, it will show me if that window was actually open, or if I made a math error, or something else. MessageModal will pause the script until you click 'OK', then continue with the next line(s).

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Mar 12, 2003 6:21 am

As Captive mentioned there are lots of ways.....

Another approach would be to write a temp file at the end of process 1.
Check for temp file exist before start process 2.
If no temp file, wait, jump back to test for temp file.
When temp file exists, delete it, and start process 2.

Other ways will show up here too, but RP_WAIT is probably the best solution.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Re: Need help Waiting

Post by support » Wed Mar 12, 2003 8:38 am

rlchase wrote:Run Program>C:\Program Files\Common Files\Command Software\csav /all /Delete /list /report=C:\myreport.txt /append C:\a
WaitWindowClosed>C:\Program Files\Common Files\Command Software\csav
Messagemodal>END!!!
*Immediately* after csav has been spawned by Run Program and it is just beginning to get started and appear on screen your script is now waiting for it's window to NOT exist. At this stage it may well not exist .. yet. So the script moves on. Ooops. What you really want to do is:

Run csav
wait for it's window to open
wait for it's window to close
now end

Run Program>C:\Program Files\Common Files\Command Software\csav /all /Delete /list /report=C:\myreport.txt /append C:\a
WaitWindowOpen>C:\Program Files\Common Files\Command Software\csav
WaitWindowClosed>C:\Program Files\Common Files\Command Software\csav
Messagemodal>END!!!

Easier would be to use RP_WAIT=1

Let>RP_WAIT=1
Run>C:\Program Files\Common Files\Command Software\csav /all /Delete /list /report=C:\myreport.txt /append C:\a
MJT Net Support
[email protected]

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