Wait 10 seconds in WinPE environment?

I've got an interesting problem; I've developed a set of bootable USB sticks on which I've put WinPE (64-bit Vista version).  When startnet.cmd is called, it executes wpeinit, which takes about 7 secs to complete, and then I run my scripts.
However, the script (map.bat) attempts to make a network connection, but I find system cannot find the network path.  If I wait 10 seconds and run the map.bat again, it works fine.
So I started trying to 'wait' in my script.
To cut a long story short, I can't ping x.x.x.x -n 1 -w 10000, because IP isn't yet configured (even and errors without waiting.  I've tried;
attempt map 1
ping for 2 seconds
attempt map 2
ping for 2 seconds
attempt map 3
ping for 2 seconds

I've tried computerhope's sleep command, but as it's a WinPE x64 env, the program doesn't run.

My latest attempt was to do an ipconfig /renew as the first command, but but it complains of no adapter being in the correct state; so I suspect the network driver isn't 'up' yet.

Any ideas?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ping -n 10 localhost

maybe a few bogus "systeminfo>NUL" commands? Systeminfo.exe usually takes 3-4 seconds (not sure about a PE environemnt, but >NUL at least keeps teh errors offscreen.....
It's been awhile since I did .BAT files, but what about a FOR-NEXT loop to kill about 10 seconds?
Steve KnightIT ConsultancyCommented:
a one line vbscript perhaps:

@echo off
echo sleep 10>wait.vbs
cscript wait.vbs

if ip isnt up at all then the localhost probably wont respond either.

or you could use choice.com if that is on there and works.

Or if you want an exe there is an ancient one called waitsecs.exe on my downloads page at http://www.dragon-it.co.uk/

only passing, sure youll have an answer out of that lot somewhere or someone else will shortly.

Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

BTTrainingAuthor Commented:
Thanks for the suggestions.  
@John, the localhost option isn't any different from pinging, and as IP isn't up yet, that doesn't cause the delay I want.
I've thought of running commands >NUL a few times, but I'm struggling to think of one that will cause a long delay rather than an instant error (such as ipconfig /renew).
I'll try systeminfo, though I can't imagine why WinPE would need it

@dragon-it, I'll give that a go, my PE environment supports scripting, so I'd imagine cscript is in there.  The only trouble I'm encountering is returning from an external program back in the flow of this one.  For instance, I wrote a script called both.bat. it contains two lines;

REM first script called

REM second script called when first is finished


testFirst.bat has one statement ; echo First Worked
testSecond.bat also has one statement; echo Second worked

When it runs, only the first string (First Worked) is output.
I've tried &&ing them and it sitll doesn't appear to work.

In old DOS scripts I remember adding & to a line to have it run in the background, will that help here?
Steve KnightIT ConsultancyCommented:
you can use call to go to another script and come back.  cscript running a vbscript is just a program effectively so it just carries on at next statement anyway.

You can do multiple commands onoone line with & like you say.

Steve KnightIT ConsultancyCommented:
BTW My previous example was somewaht flawed, I missed out "wscript" and paused for 10ms not 10s :-)

@echo off
echo wscript.sleep(10000)>wait.vbs
cscript wait.vbs

You can point the wait.vbs elsewhere, e.g. %temp% or have it already there rather than create it, i.e.

@echo off
echo wscript.sleep(10000)>"%temp%\wait.vbs"
cscript "%temp%\wait.vbs"

or you could have a file already there called wait.vbs which pauses the number of seconds from command line, e.g.

'save this as wait.vbs
wscript.sleep (WScript.Arguments(0) * 1000)

and run it with:

cscript //nologo wait.vbs 10

Obviously you could add error checking and the like but not really needed for this !


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve KnightIT ConsultancyCommented:
Not a bad plan in there actually... rather than a forced wait for 10 secs use a PING and keep looping until it doesn't return an error... I wasn't thinking PE specific just answering the ask for a 10 sec delay!
BTTrainingAuthor Commented:
Going to try this today, will let you know how it goes!
BTTrainingAuthor Commented:
Just updated my boot sticks, I went with The Deployment Guys via FirstSentinel's solution, love the simplicity of it, and it works a treat.  Zero touch rebuilds of XP have just been done on 40 PCs this afternoon, brilliant.  Thanks to Dragon-it for your efforts too!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.