Solved

Batch file - wait time

Posted on 2011-03-06
4
1,114 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

734 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