You can try something like this
Main Topics
Browse All TopicsI have a tiny script that looks in a directory for a file. I need to modify the script so that it does the following:
1. If the file exists, END
2. If the file does not exist, wait 5 seconds and look again.
I think it would be bad to loop the script for ever so I would also like to limit the number of loops so that if the file never exists, the script will END [or even better, throw an error or write to the event logs or something like that].
I have tried a couple of things without success. This is different than .Net, I think, so I'm not sure if I can use Sub to loop through.
FYI - this script will be used in an application that allows the use of vb script so it will not be a stand alone application or anything like that [if it matters].
Thank you,
Jason
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Well,
I turns out that WScript calls can not be used in the application I intended to use this script for. Here is an article that gives an explanation:
http://support.microsoft.c
Is it possible to accomplish what I want to accomplish without referencing WScript Functions?
Let me know,
Jason
BlueDevilFan,
Sorry for not being more clear. We recently installed an application called PlanetPress. It handles form overlays, printing, and faxing of forms and documents. One feature of the application is the ability to run embedded vb scripts OR calling an external vb script.
There is one processes I am working on which requires me to monitor a directory for a file. when that file exists i need to continue on with the planet press process. when the file does not exist i need the planet press process to wait until file does exist. The vb script we are working on will handle this.
I didnt realize that using wscript would be a problem. I think the wscript.sleep is the issue as some wscript functions appear to work.?.?.?
Jason
Ahh I see your problem the application is probrably using microsoft scripting control. You can use the Wscript objects but the core methods like Sleep() don't exists only the specific objects like Shell,Network etc.. This means you will need to either create an ActiveX.DLL and implement the Sleep() API in there and use CreateObject() on your ActiveX.dll. You could probrably use the Timer object to create a custom sleep as well.
yep, i think you are correct. i also thought of something else....
I should be watching to see if the file has completed being written. i mean, i cant continue with the planet press process unless the file has completed being written to the file path.
know what i mean?
what do you recommend that i do?
As a work around i am using this script to act as a delay timer. it is a hack but is working. it will fail if a file takes longer than 6 seconds to be exported and written to the file path specified in the script.
what do you think of this script? can we work with this in some way?
Jason
Well you can only do this from scripting if the file will be a static size like 1024 bytes. Otherwise you will need to create another loop and check if additional bytes are still being written to that file. This is especially the case if the application writing to the file gives share access. However if the application writing to the file gives no access you could check for runtime error and this will only work if the application closes the handle immediatley after it finishes writing. It will be hard to come up with any kind of solution without knowing any information about the file.
Business Accounts
Answer for Membership
by: BlueDevilFanPosted on 2009-10-29 at 08:55:02ID: 25695058
This should do it.
Select allOpen in new window