windows-service
如果存在的话我想执行以下命令:
myservice.exe uninstall
myservice
我的 Windows 服务名称在哪里?
我努力了:
$serviceName = 'simpleservice'
If (Get-Service $serviceName -ErrorAction SilentlyContinue) {
If ((Get-Service $serviceName).Status -eq 'Running') {
Stop-Service $serviceName
Write-Host "Stopping $serviceName"
} Else {
Write-Host "$serviceName found, but it is not running."
}
path\to\my\service\$serviceName uninstall
} Else {
Write-Host "$serviceName not found"
}