views:

84

answers:

1

I am writing a windows batch script to uninstall some software. However I need to wait after the uninstaller has finished for a service to be restarted before continuing with the next uninstall.

I can make the script wait for the uninstaller to finsh using:-

for /f "usebackq" %%M in ('tasklist /nh /fi "imagename eq %process_1%"') do if not %%M==%ignore_result% goto 1

But I cannot for the life of me figure out how to get the script to then wait for a service to start before continuing the script and running more uninstalls.

I am open to any suggestions.

A: 

OK from comments I have used the script below to sort out the problem. I was hoping not to use a intermediate file, but when needs must....

@echo off
if exist service.txt del service.txt
set process=setup.exe
set ignore_result=INFO:
:1
for /f "usebackq" %%M in ('tasklist /nh /fi "imagename eq %process%"') do if not %%M==%ignore_result% goto 1
:2
sc query AcquisitionService>service.txt
find "RUNNING"<service.txt>nul
if errorlevel 1 goto 2
:3
echo.
echo Stuff finished.......

Thanks for the ideas.

Shane McD