I want to have a script that starts a program that creates files, have the script know when the file has been created, then terminate the program and do some post processing with the created file. I have already scripted the post processing scripting and it works well. I can also get the program that creates the file to start and do the file creation. The problem is finding a way to make the script wait till the file was done being created to do the post processing scripting. Using sleep/wait statements is not an option as the time it takes to create the file will vary with different sizes of files. I have come up with the idea of having the PROGRAM create 2 files. The first would be the file that I actually want to do the post processing on (The GOOD FILE) the second would just be a dummy file that would act as an alerter that the file to be post processed was ready! Is it possible to get a .vbs script to watch for the appearance in a certain location/directory of a file with a specific name.... To further complicate this endeavor the script will be fired multiple times and I do not want multiple instances of the PROGRAM that creates the file operating at the same time, so I would like when the script that fires the PROGRAM starts that it check to see if the PROGRAM was already running, and if so wait till it was killed before starting the process all over again.

I have placed a bit of a flow below of what I am looking for.

1. Script is started via call from ASP script (ALREADY DONE)

2. Script checks to see if the PROGRAM is running (NOT DONE)

3. If PROGRAM is NOT running then it is started and script waits for FILE2 to appear in a directory. If running then wait till it is killed then start PROGRAM. (NOT DONE)

4. PROGRAM creates FILE 1 - Real File (ALREADY DONE)

5. PROGRAM creates FILE 2 - Dummy File script was waiting for to move on(ALREADY DONE)

6. Script kills PROGRAM (NOT DONE)

7. Script performs post processing on FILE 1 (ALREADY DONE)

8. Script Deletes FILE 2 and moves FILE 1 to another directory(ALREADY DONE)

I can do allot of the scripting myself I just need help with the more advanced stuff. Also these directories are networked folders. That can be changed though if needed. I do not know what .vbs files have access to do.