Solved

Batch file - wait time

Posted on 2011-03-06
4
1,079 Views
Last Modified: 2012-05-11
Hi,
      I need to create a batch file that needs to have two commands in there, but it has to wait for the first command to finish before executing the second command.  I know I can probably put a sleep statement in-between the two, but I cannot be certain that my 'sleep' will always be the same.

Here are the two commands that I need in the batch file

ewfmgr c: -commitanddisable -live

Open in new window

ewfmgr c: -enable

Open in new window


Thank you!
0
Comment
Question by:arunykand
  • 2
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
sjklein42 earned 500 total points
ID: 35048875
Putting in a loop like this between the two commands should stall it until the first command takes effect:

:waitForDisabled
sleep 1
ewfmgr c: |findstr DISABLED >nul:
if ERRORLEVEL 1 goto waitForDisabled

Open in new window

0
 

Author Comment

by:arunykand
ID: 35048917
Will this also ensure that the command window will stay open after it is complete?  I want the window to stay open and wait for the user to close the window.

Thanks
0
 
LVL 16

Expert Comment

by:sjklein42
ID: 35048978
Here's the whole thing.

First does -commitanddisable.
Then loops until the device shows DISABLED status.
Then enables it.
Then waits for user to type any key to close the window.

ewfmgr c: -commitanddisable -live 

@:waitForDisabled
@sleep 1
@ewfmgr c: |findstr DISABLED >nul:
@if ERRORLEVEL 1 goto waitForDisabled

ewfmgr c: -enable

@pause

Open in new window

0
 

Author Comment

by:arunykand
ID: 35049757
Great, thanks!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Many times while working on a computer regardless of any Operating System, lag and crashes seem to creep in, hindering your working speed. Sometimes, it can also cause your work to be lost unexpectedly and as a result, you are unable to meet your de…
Utilizing an array to gracefully append to a list of EmailAddresses
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now