Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what is the dos command that acts like 'sleep'?

Status
Not open for further replies.

pho01

Programmer
Mar 17, 2003
218
0
0
US
what is the dos command that acts like a sleep command? tnx

 
try "pause". this will stop the batch until you press a key.
 
no, that's not what I'm looking for. somethings like - described in english:

connect to a drive
do something
write something to a file
wait for 60s for the job to complete
do a second task

i want this to run automatically as a scheduled task, but need to wait some times for the previous task to complete first, then do a second. otherwise dos complains because the previous task didn't have enough time to complete just yet.

so something like a sleep command in unix shell. does anybody know if dos supports it?
 
Windows does have a sleep command but it is available separately in the resource kit tools.
You can get the latest version from microsoft at:

The above link is for the windows 2003 resource kit tools and should work on win2K. If not sure , you can always download the Win2k Resource kit tools . I believe that NT had the same tool as well.



Claudius (What certifications??)
 
You should look at doing your task as a VBScript file. Then you can actually use the wscript.sleep command.

Give some details on what you actually want to accomplish and I can help you with the script code.

But, based on what you are asking for above, here is code that will do what you ask.

Code:
'======================================
'
' NAME: <filename>
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 6/29/2004
'
' COMMENT: Example script
'
'======================================

Dim WSHNEtwork, WSHShell, fso, ts
Const ForWriting = 2


Set WSHNetwork = CreateObject("WScript.Network")
Set WSHShell = wscript.createObject("wscript.shell")
Set fso = CreateObject("Scripting.FileSystemObject")

'Connect to a drive
WSHNetwork.MapNetworkDrive "U:", "\\server\users",True

'Do Something
Call WSHShell.Run("cmd.exe /C Del C:\Temp\*.tmp /q")

'Go to sleep for a while
Wscript.sleep 500

'Write something to a file
Set ts = fso.CreateTextFile ("C:\ActionLog.txt", ForWriting)
report = "All temp files in C:\Temp Deleted"
ts.write report

'Do Something Else
Call WSHShell.Run("cmd.exe /C Del C:\Windows\Temp\*.tmp /q")

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
in all of the windows resource kits 'wait.exe' is available



wait 60
 
One option is to create a separate batch file called wait.bat. Put the following in the file:

Rem ##Issue "choice" statement and default to "N" after %1% seconds.
@CHOICE /T:N,%1% > NUL

Then, in your main script, call the wait.bat script with the following statement wait nn

This will call the wait script, issue a prompt for Y or N, and when no answer is given, default to N after nn seconds.

Also, the sleep.exe command is available, and is called as follows:

sleep nn

with nn being the # of seconds to sleep.

sleep and choice are both available with the Windows Resource Kit.

Check out for listing of DOS Commands.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top