Determine if Program is running

General Macro Scheduler discussion

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Determine if Program is running

Post by kpassaur » Wed Jul 07, 2004 2:12 pm

I have looked and read about everything posted now and I am stuck. I want to Obtain a list of files and process them. I can get the list from one directory (but not subdirectories - another issue) and process them; however, I need to wait until the first is finished before the second one starts. I cannot use "Wait" as one file may take 1 second to process and the next 1 hout to process. However, the program automatically exits when the file is processed. So, I need to know how to determine when a program is not running. I saw the VB example with IE; however I don't know if it can be used in this case and without a descripition of what each line does in that example I cannot figure it out. So far the script looks like this:

(I left the message boxes in for testing they will be removed)



GetFileList>c:\testtif\*.*,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%

Let>k=0
Repeat>k
Let>k=k+1
Let>fname=file_names_%k%
//Run Program>C:\Program Files\Common Files\Microsoft Shared\MSPaper\mspview -f "%fname%"
//Wait>30
MessageModal>fname
Until>k,file_names_count

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 Jul 07, 2004 3:05 pm

The magic tool here may be RP_WAIT

Use RP_WAIT before you use Run Program. That will delay processing of any other script lines until the program has been completed. Something like this:
Let>RP_WAIT=1

Run Program>C:\Program Files\Common Files\Microsoft Shared\MSPaper\mspview -f "%fname%"

Let>RP_WAIT=0
This is only needed for Run Program or Execute commands. The normal Macro Scheduler commands will wait until each is done before running the next line.

====================================

You can also get the list of files in a sub directory by using the DIR command, redirect to a file, Read the lines in that file and sent them to %files% like you did with GetFileList. Let something like this replace your first line, GetFileList:
Let>RP_WAIT=1
Run Program>command.com /c DIR c:\testtif\*.*/s >c:\filelist.txt
Let>RP_WAIT=0

Let>k=1
Label>ReadLoop
ReadLn>c:\filelist.txt,k,line
If>line=##EOF##,Finish

//You can put the logic in here to strip out filename lines
//Maybe use MidStr to check that position 15-18 is blank?
//IF>Line is a filename then Write to %Files%

Let>k=k+1
Goto>ReadLoop

Label>Finish
Separate>files,;,file_names
Notes
1. The script above is untested, concept only at this point.
2. Also use cmd vs. command for XP/2K/NT systems.
3. And be sure to remove trailing spaces from Cut/Paste from forum samples. Use the Editor, click on Edit, Show All Chars and Remove Trailing Spaces to eliminate them.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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