param([string]$InstallDir="C:\Program Files\EgalWare\Maat.Runner"); # funzione verifica servizi function Confirm-WindowsServiceExists($name) { $server="localhost" if (Get-Service -Name $name -Computername $server -ErrorAction SilentlyContinue -ErrorVariable WindowsServiceExistsError) { Write-Host "$name Exists on $server" return $true } if ($WindowsServiceExistsError) { Write-Host "$server" $WindowsServiceExistsError[0].exception.message } return $false } # mi sposto nella directory CD $InstallDir ## verifico se ci fosse già il servizio e lo disinstallo nel caso #if(Confirm-WindowsServiceExists("Maat.Runner")) #{ # # stop servizio # ./nssm.exe stop Maat.Runner # # ## elimino servizio installazione # #./nssm.exe remove Maat.Runner confirm #} # avvio installazione ./nssm.exe install Maat.Runner "$InstallDir\Maat.Runner.exe" # configurazione directory ./nssm.exe set Maat.Runner Application $InstallDir\Maat.Runner.exe ./nssm.exe set Maat.Runner AppDirectory $InstallDir # descrizione + autostart ./nssm.exe set Maat.Runner DisplayName "Maat.Runner" ./nssm.exe set Maat.Runner Description "Egalware Maat Runner Service" ./nssm.exe set Maat.Runner Start SERVICE_AUTO_START # set logfile ./nssm.exe set Maat.Runner AppStderr $InstallDir\logs\stderr.log ./nssm.exe set Maat.Runner AppStdout $InstallDir\logs\stdout.log ./nssm.exe set Maat.Runner AppStdin $InstallDir\logs\stdin.log # avvio il servizio ./nssm.exe start Maat.Runner