General discussion

Locked

How to make script wait?

By magisnyc ·
I have a script (.vbs) which at one point copies files to a new directory. The file copy must finish before executing the next command in the script. The size of the files will change over time. How do I get the script to check if the copying is complete before going to the next line?

I'm new to scripting so any insight you can give would be helpful.

Thanks.

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

How to make script wait?

by Ann777 In reply to How to make script wait?

You cannot really have the script check as to when the copying is complete.

There's a command that causes the script to wait for a time. So essentially you need to plan for the longest time that the copy will take and have the script "sleep" for that period of time.

Lookup "sleep" and remember that every number is .001 of a second ; if you do sleep 100 that means one second.

Collapse -

How to make script wait?

by Ann777 In reply to How to make script wait?

Another alternative is to setup a phandle command and a waitforsingleobject and closehandle

This funtion basically waits for another exe file finish and then it will procced. It is a very cool funtion; that way you can have multiple exe files instead of one really big executable and being carefull that the commands don't conflict with another

Collapse -

How to make script wait?

by magisnyc In reply to How to make script wait?

Windows 2000 doesn't normally support the "Sleep" command unless you have the resource kit installed - plus the fixed time that you would enter would not adjust as the size of the file changes (the script runs a daily backup of a database) I did however receive an answer that worked for me:

If you are using the .CopyFile method of the File Scripting Object, the script will wait until the file is copied before preceeding to the next line.
If you are copying the file using the DOS command 'Copy' with WshShell.Run, WshShell.Run has a parameter to tell the script to wait for it to finish. Such as:

WshShell.Run "cmd /c copy Oldfile.ext Newfile.ext",,TRUE

The TRUE tells WshShell.Run to wait (default is FALSE). Note the double comma,the missing parameter is the window style (Minimized, Maximized, etc)

Collapse -

How to make script wait?

by magisnyc In reply to How to make script wait?

This question was closed by the author

Back to Windows Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums