@@ -598,37 +598,47 @@ if ($Restart) {
598598 $ProcessName = $LivelyBin
599599 }
600600
601- Write-Host " Shutdown Lively…`n "
602- & $LivelyBin -- shutdown true
601+ $process = Get-Process - Name $ProcessName - ErrorAction SilentlyContinue
603602
604- # Wait the process to be stopped but continue the script if process still running after 10 seconds
605- Wait-Process - Name $ProcessName - Timeout 10 - ErrorAction SilentlyContinue
603+ if ($process ) {
606604
607- Start-Sleep - Seconds 2
605+ Write-Host " Shutdown Lively…`n "
606+ & $LivelyBin -- shutdown true
608607
609- # Need to check if no other instance is running
610- $process = Get -Process - Name $ProcessName - ErrorAction SilentlyContinue
608+ # Wait the process to be stopped but continue the script if process still running after 10 seconds
609+ Wait -Process - Name $ProcessName - Timeout 10 - ErrorAction SilentlyContinue
611610
612- if ( $process ) {
611+ Start-Sleep - Seconds 2
613612
614- Write-Host " Lively process still detected, tring to kill it…" - ForegroundColor Yellow
613+ # Need to check if no other instance is running
614+ $process = Get-Process - Name $ProcessName - ErrorAction SilentlyContinue
615615
616- Stop-Process - InputObject $process - Force
617- Wait-Process - InputObject $process - ErrorAction SilentlyContinue
616+ if ($process ) {
618617
619- $processCheck = Get-Process - Name $ProcessName - ErrorAction SilentlyContinue
618+ Write-Host " Lively process still detected, tring to kill it… " - ForegroundColor Yellow
620619
621- if (-not $processCheck ) {
622- Write-Host " Success : Lively has been stopped." - ForegroundColor Green
620+ Stop-Process - InputObject $process - Force
621+ Wait-Process - InputObject $process - ErrorAction SilentlyContinue
622+
623+ $processCheck = Get-Process - Name $ProcessName - ErrorAction SilentlyContinue
624+
625+ if (-not $processCheck ) {
626+ Write-Host " Success : Lively has been stopped." - ForegroundColor Green
627+ }
628+ else {
629+ TerminateWithError - errorMessage " Fail : Lively still active."
630+ }
623631 }
624632 else {
625- TerminateWithError - errorMessage " Fail : Lively still active. "
633+ Write-Host " Success : Lively has been stopped. " - ForegroundColor Green
626634 }
635+
627636 }
628637 else {
629- Write-Host " Success : Lively has been stopped. " - ForegroundColor Green
638+ Write-Host " Lively is not running. "
630639 }
631640
641+
632642 Write-Host " `n Starting Lively…`n "
633643 & $LivelyBin -- showApp true
634644
0 commit comments