Skip to content
Snippets Groups Projects
Commit d3a2a423 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Add a service installation script using NSSM

parent 5302c5f9
No related branches found
No related tags found
No related merge requests found
$ServiceName = "citrix_collector"
# $ServiceName = "grafana"
$NSSMExecutable = "C:\Tools\NSSM\nssm-2.24-101-g897c7ad\win64\nssm.exe"
$PSExecutable = (Get-Command Powershell).Source
$BaseDir = $PSScriptRoot
try {
$Service = Get-Service -Name $ServiceName -ErrorAction Stop
}
catch {
Write-Host "Service $ServiceName not found, installing..."
}
if ($null -ne $Service) {
Write-Host "Service $ServiceName is already installed! Doing nothing."
exit
}
# required arguments, including the path to the script
$Arguments = "-ExecutionPolicy Bypass -NoProfile -File `"$BaseDir\citrix_collector.ps1`""
# install the service
& $NSSMExecutable install $ServiceName $PSExecutable $Arguments
# set a log file for stdout and stderr
& $NSSMExecutable set $ServiceName AppStdout $BaseDir\citrix_collector.log
& $NSSMExecutable set $ServiceName AppStderr $BaseDir\citrix_collector.log
& $NSSMExecutable set $ServiceName AppTimestampLog 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment