Doing a timed pause of a batch file that works on all windows vers, and works by default.

I am looking for a way to pause the execution of a batch file for a few seconds, but there is a huge twist.
It needs to work on Windows 98, 2000, and XP without downloading any files.

This batch file gets started before the network is started, and tries to launch a networked file, so we need to slow it down by about 30 seconds, waiting for the network to finish loading. That being said, a ping command won’t work since there isn't a network and it will fail at the start. Second, “choice” only works on the 98 computers; “sleep” only works if we download it to all 1000 computers, “at” requires us know an exact time.

Does anyone know any tricks as to how to use one command, that is on 98, 2000, and XP by default, to pause a batch file? Any help would be great; days of googleing have returned nothing.
remyservicesAsked:
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.

dmoxCommented:
Put it in the startup folder?  Nothing gets executed in the startup folder until the OS has finished loading...
0
StGoYCommented:
A simple, yet not very ethical way to solve this would be to get your batch file to run through a loop during these XXseconds
Since there are no commun apps given through windows that pauses a batch files, it's the only way I can see...
As for what operation to do in your loop, it's up to you.  Anything could do the trick, really... You could ask the system's time 3k times if you like, juts as long as you occupy your system for XXseconds!!
A problem with this technique... It's all depending on the system's speed... so don't test it on your slowest system first :P

But i don't get it... why don't you simply download the sleep exe onto your server, then specify it's path in your batch file?!?
ex:
\\Yourserver\Share\Sleep.exe 15000

Now that I've answered your question...  How the hell do you call a batch file before the network loads up?!  Even if it's a startup script, the network connections are still loaded!!  By "before the network is started" do you mean before the network drives have been mapped??

Hope this helps
Steph
0
remyservicesAuthor Commented:
As to putting it in the startup folder, we can't do that due to the fact this script is run as a system user, by a service, and no-one logs onto the system. Therefore the startup menu would never run any programs.

Running a sleep command from the server wont work ether, it it would we wouldn't need to sleep the script.

To explain the whole story behind how it is launched, we use DeepFreeze Enterprise. http://www.faronics.com This program allows a maintenance mode that will run a batch file. We have contacted the company and they know of the issue, but don’t have a fix yet. This service, program, whatever they run as, intergrades very deeply into the system. Every time you reboot the computer it is like it is re-cloned. When in maintenance mode, the system restarts, locks the keyboard and mouse, and runs are script in the background. The issue is that they run the script, pre waiting for the system to fully load, hints no network until a few seconds after, and it runs the script while the logon window is there. We can push out a new batch file to all 1000 computers in under 2 seconds, but if it isn’t 98, 2000, XP compatible it will blow up on those it isn’t.

What we have now is nothing more then \\server\start_updates.exe but at the time this executes (before the network services are even started) it can’t find the file so it is done.
The objective is to add a 30 second pause before that running that is OS independent and network independent.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

StGoYCommented:
Humm I see, that's an interesting concept!  Do you mind if I ask you what kind of company you work in? (Nothing but curiosity here)

Let's see now, if your machines are completely recloned at startup, why not include the sleep.exe application in your base image?  Then you could call it directly from the local machine while avoiding the task of copying the tool to your 1k machines?  Only suggesting, since I don' t know how that DeepFreeze program do run (Didn't even know the program either!)

Else, as I said earlier, I don't know of any windows' based app that could pause your program.  So your left (in my oppinion) with the 30second loop option...

BUT (just thought of it) Couldn't you use a VBS instead?  If so, you could do somthing like this :

**********
Dim WshShell

Set WshShell = WScript.Createobject("WScript.shell")

Wscript.Sleep(30000)
WshShell.run "\\server\start_updates.exe"

Set WshShell = Nothing
**********

Don't know if this is portable to Win9x

We'll slowly find something.... won't we? :P
Steph
0
remyservicesAuthor Commented:
I work for Academy School D20 here in CO just so you know.
The "cloning" is self restoring I guess is how you would state it. The systems are "frozen" and from that point on, all bios calls are disabled, and you can format the hard drives from within windows and on reboot it all comes back within a few seconds. Much like GoBack if you are familiar with that program, but much more advanced. There is a $1000 reward for anyone who can make a permanent change to the HD or BIOS while the system is frozen. So the re-cloning can’t really include any new files unless we actually do use Ghost and re-clone all 1000.

FYI: in this maintenance mode the systems are “thawed” which allows changes to be kept until next “freeze”

Using a vb script would be great, but for now they only support adding batch file commands.
0
EricCommented:
could you use a batch file like below ???


IF "%OS%" == "Windows_NT" GOTO NT_Pause
IF "%OS%" == "Windows_98" GOTO 98_Pause

:NT_Pause
echo "Windows 2K/XP Pause Goes Here"
pause
goto END

:98_Pause
echo "Windows 9X Pause Goes Here"
sleep
goto END

:END
echo "Ending Program Now"
0
snickeredCommented:
I don't have a Windows 98 machine around me, but I don't think that %OS% is a variable in Windows 98.  You would probably want to change that if statement to something like:

IF "%OS%" == "Windows_NT" GOTO NT_Pause
IF "%OS%" == "" GOTO 98_Pause
0
Jasonw3Commented:
I used Deep Freeze in a university setting and we used Active Directory GPO to run startup batch files that were necessary, then placed a .txt marker file on the system where the file was successfully executed and then ran an if exist command in the batch file.  The good thing about this method is that the GPO startup waits until everything is loaded.

With that being said, why can't you simply use the enterprise remote control to execute a thaw command.  Once the systems are restarted, then manually execute the batch file, then wait 5 minutes or so and execute a freeze.  It should allow for that.
0
Jasonw3Commented:
....and when I said manually execute the batch file, I mean manually use Deep Freeze's Management tool to run the batch file.
0
remyservicesAuthor Commented:
Using GPO would be great, but we don't run a domain, and we wish we could but CO won't allow it. we will try using a batch that finds the OS, we might be able to get away with that. With 98 we could use a choice that times out, but what about XP and 2000? what is builtin that we could use to sleep it.
0
Jasonw3Commented:
Download sleep and copy it to the location desired:

http://www.computerhope.com/download/utility/sleep.exe

Then Run:

Sleep <#of seconds delay>
0
Jasonw3Commented:
After thinking about it some more, why not just copy the choice files from a previous version of DOS.  Here is the supplemental toolkit:  http://support.microsoft.com/?kbid=117600

That way you don't have to worry as much about deciphering the OS in the batch.
0
tymesCommented:
Normally I would indeed use "PING 192.168.231.132 -n 30 -w 1000" to wait 30 seconds but...


:WAITING
IF NOT EXIST \\NETWORKDRIVE\NETWORKFILE.TXT  goto :WAITING


You _CAN_ use VBSCRIPT, just create the vbscript file from within the bat file...

ECHO Dim WshShell >%temp%\wait30.vbs
ECHO Set WshShell = WScript.Createobject("WScript.shell") >>%temp%\wait30.vbs
ECHO Wscript.Sleep(30000) >>%temp%\wait30.vbs
cscript %TEMP%\wait30.vbs



What else...   perphaps

if "%OS%"  equ "Windows_NT" goto :NewWIN
:OldWIN
choice /c1 /t1,30 |echo
goto :CONTINUEBAT
:NewWIN
for /L %%x in (1,1,30) do call :wait1second
goto :CONTINUEBAT

rem subroutine to wait 1 second
:wait1second
set xseconds=%TIME:~6,2%
:wait1secondmore
if %xsecond% equ %TIME:~6,2% neq  goto :wait1secondmore
goto :EOF

I might change the wait to do some math...

:wait30seconds
set xseconds=%TIME:~6,2% + 30
if "%xseconds%" geq 60  set /a xseconds=%xseconds%-60
:waitsomeseconds
if "%xsecond%" neq "%TIME:~6,2%"  goto :waitsomeseconds
goto :EOF


Is that three solutions?
0

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
remyservicesAuthor Commented:
Well, a new start to a new day... I will try out a few of these.

this might be great if it dosn't lag to badly, we will see
:WAITING
IF NOT EXIST \\NETWORKDRIVE\NETWORKFILE.TXT  goto :WAITING

and this is what I was trying to do in a since, find what second it was, but I couldn't seperate out the hour min and second, so I would love an explanation of the ~6,2
set xseconds=%TIME:~6,2% + 30
0
tymesCommented:
the waiting for a network resource to appear might only wait 3 seconds or a variable amount of time each time (rather than 30seconds when it only 3 seconds to connect) or it may hang if it never shows up in which case if there was no network it might hang anyways.  Just wait there for the thing your actually waiting for.

On a windows 2000/xp machine, I might also do a "FOR /F "some options" %x IN ('ping server -n 1') DO" type thing to parse the results of a ping looking for the text "Reply" as apposed to "Hardware" from hardware error or "Request" from Request timed out.  I used to have a script that looked at the time=<1ms or time=153ms in ping responses to determine if a user was local or remote (I eventually switched that to look for the default gateway in a ROUTE PRINT command to find their locationrather than if they were just slow).

The "set /A xseconds=%TIME:~6,2% + 30"  (woops, forgot the /a which is needed to do the math) takes the seconds and adds 30.   Look at "SET /?".  That doesn't work on Win9x -- where nothing works like the FOR /F %x.  

Also I noticed the "choice /c1 /t1,30 |echo" or a "CHOICE /Ty,30" command that I used to prompt 30 seconds in win9x for a key press would be bad if someone could press a key and actually did press a key (so if the script was ever in the forground was ever an active task which I think is probably ok or someone could just press control C) -- if it the right key it would stop waiting and continue and if it was the wrong key it would wait indefinately.  So the problem is still trying to wait for 30 seconds in win9x.  

Now this is a good 250 point question but that $1000 question....
0
remyservicesAuthor Commented:
This script will be 100% in the background and there is no way for a user to interact since the keyboard and mouse is locked down. so for 98 I can use a choice /t:y,15 /n and then on XP use :WAITING
IF NOT EXIST \\NETWORKDRIVE\NETWORKFILE.TXT  goto :WAITING
I wont get a chance to try this till Friday at the soonest, but please don't stop giving advice.
0
bruceleroyCommented:
You can use a simple script to determine th OS:
echo.
if exist "c:\Documents and Settings" goto win2k (or XP)
if exist c:\windows\desktop goto win95
if exist "C:\WINDOWS\All Users\Desktop" goto win98
if exist "c:\winnt\profiles\all users\desktop" goto winnt
goto end

Hope this helps
0
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
Operating Systems

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.