How can i make a batch file to wait for 10 seconds before cotinuing.
Printable View
How can i make a batch file to wait for 10 seconds before cotinuing.
You could write a vb program to sleep for 10 seconds, and call it from the batch file. Don't know of any time commands in a batch file. You could have the batch file wait for another process to finish, though.
I used Choice.com till now. But it wasn't ship with xp. So i was hoping someone can tell me of an alternative way.
To do what dglienna suggested start a new standard EXE project. Remove the standard Form and add a BAS module instead. Change the startup object of the project to Sub Main and add the following code to the module.Save the project as Wait.vbp (or whatever) and compile it. Now in your BAT file you can run this application like this:VB Code:
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long) Public Sub Main() If Not IsNumeric(Command$) Then MsgBox "Usage: Wait interval" & vbCrLf & vbCrLf & _ "Interval is a numeric time to wait expressed in milliseconds." Else Call Sleep(CLng(Command$)) End If End SubCode:@echo off
echo Wait for 10 seconds
c:\thePath\Wait.exe 10000
echo Done!
I am looking for a way without having to install any app.
There must be some trick.
Well this is a VB forum so why are you asking this question here if you didn't want to use VB to solve it?
I think that MSGBOX might be a bad choice - as if this runs in a .BAT file on a server, for instance, that will pop-up on a screen not being watched...
Maybe some kind of PRINT statement to the console? Not sure how that works though...
Well, the MsgBox will only appear if you don't pass the interval the app should wait before it exits so if it appears you haven't debugged your BAT file before you put it on the server. But attached is a C program that does exactly the same thing as my above VB code except that it's a console app.Quote:
Originally Posted by szlamany