Computing.Net > Forums > Programming > Doing a Wait in Batch File

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Doing a Wait in Batch File

Reply to Message Icon

Name: ace_omega
Date: September 11, 2009 at 15:37:42 Pacific
OS: Windows 2003 Server
CPU/Ram: Quad Core / 4Gig
Product: Hewlett-packard SERVER
Subcategory: Batch
Comment:

I need a wait ability in a Batch file to wait for a service to stop before it continues to the next command. Here is my code...

sc stop "Backup Exec System Recovery"
del "C:\Documents and Settings\All Users\Application Data\Symantec\FileBackup\catalog.dat"
sc start "Backup Exec System Recovery"

I need a wait after the SC because it will not delete the file while the service is still running.



Sponsored Link
Ads by Google

Response Number 1
Name: ricardo647
Date: September 11, 2009 at 16:31:31 Pacific
Reply:

If SC is a exe:

sc stop "Backup Exec System Recovery"
:pause
tasklist | find /i "sc.exe" >nul
if not %errorlevel%==1 goto :pause
del c:\.....


0

Response Number 2
Name: lantere
Date: September 23, 2009 at 07:37:43 Pacific
Reply:

ricardo647's solution should work.

But if you want to wait a certain amount of time, you can do
this:

PING -n 11 127.0.0.1 >NUL

That will simply ping your computer 11 times (starting now.)
It will cause the batch file to pause for 10 seconds.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


VBS String manipulation Finding text and copy usi...


Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Doing a Wait in Batch File

If else statement in Batch file www.computing.net/answers/programming/if-else-statement-in-batch-file/16954.html

Date Routines in Batch Files www.computing.net/answers/programming/date-routines-in-batch-files/15590.html

Nesting variables in batch files ? www.computing.net/answers/programming/nesting-variables-in-batch-files-/14334.html