How to stop a windows service after appveyor deployment

33 Views Asked by At

I want to stop the windows service after the appveyor deployment, only for qa environment.

I have used the following lines in deploy.ps1 file.

function SetService{
    Write-Host "Stopping service - $env:environment_name"
    if($env:environment_name -eq "QA")
    {
        Write-Host "$env:service_name"
        $serviceStatus = (Get-Service $env:service_name).Status
        Write-Host "$serviceStatus"
        Set-Service $env:service_name -StartupType Manual

            If (-Not ($serviceStatus -Eq 'Stopped')) {
            Write-Host "Stopping service $service..."
            Stop-Service $env:service_name
            }
    }
}

But, this is not working as expected, after the deployment it gets started automatically

enter image description here

How to stop the service after appveyor deployment?

0

There are 0 best solutions below