Link to home
Start Free TrialLog in
Avatar of k_hoffhines
k_hoffhinesFlag for United States of America

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!!
Avatar of Ron Malmstead
Ron Malmstead
Flag of United States of America image

Wscripts.sleep(30000)
...sorry..not wscripts

Wscript.sleep(30000)
ASKER CERTIFIED SOLUTION
Avatar of Ron Malmstead
Ron Malmstead
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of oBdA
oBdA

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.
@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.

Open in new window