k_hoffhines
asked on
Delay Start Script for application.exe
I would like to create a startup script for a couple workstation, to auto start an application but have it a delayed start for 30 seconds or be able to change for custom fit per server. The applications rely on a few services that take a while to start. I would like some kind of a script any help would be appreciated!!
Wscripts.sleep(30000)
...sorry..not wscripts
Wscript.sleep(30000)
Wscript.sleep(30000)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here's a batch script that will check a configurable list of services and only start the application (in the background) once all services are up and running.
A log file is created in the the temp folder (when running as startup script usually in %Systemroot%\temp, when started as user for testing in %Temp%).
Note that a startup script has a default timeout of 10 minutes, after which it will be kicked out, done or not, but that should be enough in your case.
A log file is created in the the temp folder (when running as startup script usually in %Systemroot%\temp, when started as user for testing in %Temp%).
Note that a startup script has a default timeout of 10 minutes, after which it will be kicked out, done or not, but that should be enough in your case.
@echo off
setlocal
set DependList="Java Quick Starter" "Alerter"
set LogFile=%Temp%\%~n0.log
>"%LogFile%" echo %Date% %Time% Waiting for services: %DependList%
:Loop
set AllStarted=1
for %%a in (%DependList%) do (
net.exe start | find /i "%%~a"
if errorlevel 1 (
>>"%LogFile%" echo %Date% %Time% Not started yet: %%a
set AllStarted=0
) else (
>>"%LogFile%" echo %Date% %Time% Running: %%a
)
)
if %AllStarted%==0 (
sleep.exe 5
goto Loop
)
>>"%LogFile%" echo %Date% %Time% All services running, starting application
start "" "T:\he\application.exe"
>>"%LogFile%" echo %Date% %Time% Done.