Archive: ExecWait with net stop wasn't working correctly, so...


ExecWait with net stop wasn't working correctly, so...
...I created another routine to serve my purpose. I call a sleeper loop and identify if the service is still running, and if so, hang until it stops. Unfortunately, the code doesn't work. I end up with a bunch of windows and it eventually dies. The second time I run it (when all services are already stopped), it works. Can anyone tell me where I'm screwing up?

<!--Code to follow-->
;NSIS Script For myApp

;Title
Name "myApp"

;Included file(s)
!include servicelib.nsh

;Do A CRC Check
CRCCheck On

;Output File Name
OutFile "myApp.exe"

;The Default Installation Directory
InstallDir "D:\Program Files\myApp"

Section "Install"

;Install Files
SetOutPath $INSTDIR
File /r "D:\myApp\*.*"

SectionEnd

Section "BringBackUp"
;Start services back up

services::SendServiceCommand 'start' 'service1'
services::SendServiceCommand 'start' 'service2'
services::SendServiceCommand 'start' 'service3'

SectionEnd


;--------------------------------
;Installer Functions


Function .onInit

InitPluginsDir
File /oname=$PLUGINSDIR\CheckProcess.exe "CheckProcess.exe"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;Shut down services;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ExecWait '"net" stop service1'
ExecWait '"net" stop service2'
ExecWait '"net" stop service3'

;wait for services to fully stop
StrCpy $1 'service1'
call SleepTilDone
StrCpy $1 'service2'
call SleepTilDone
StrCpy $1 'service3'
call SleepTilDone


FunctionEnd


;--------------------------------
; Functions


Function SleepTilDone
keepSleepin:

Banner::show /NOUNLOAD "$1 service stopping"

nsExec::ExecToStack "$PLUGINSDIR\CheckProcess.exe $1"
Pop $0
IntCmp $0 '0' doneSleepin

Sleep 1000 ;sleep for 1 second
goto keepSleepin ;check again

doneSleepin: ;it's done
Banner::destroy

FunctionEnd

<!--End Code-->

Thanks,
Eric


Bump^ - Anybody?


Move the keepSleepin: label below Banner::show

-Stu


Doh... Thanks Stu!