我有以下脚本来安装topshelf服务:
$exePath = "./My.exe"
$service = get-service | Where {$_.Name -eq "MyService"}
if($service -ne $null) {
Write-Host "Service already installed, will do a reinstall"
if($service.Status -eq "Running") {
Write-Host "Stopping service"
& $exePath stop
}
Write-Host "Uninstalling service"
& $exePath uninstall
}
Write-Host "Installing service"
& $exePath install
Write-Host "Starting service"
& $exePath start
当我运行此脚本时,我必须在每个步骤之间按Enter键。有办法解决这个问题吗?
答案 0 :(得分:0)
感谢:Richard Forrest和Tomas Jansson:
Console.ReadLine()
在控制台应用程序的结尾
ZoolWay建议:
if ((System.Diagnostics.Debugger.IsAttached) && (Environment.UserInteractive))
Console.ReadLine()
很抱歉在此答案中使用他人的想法,但我认为这有必要以100%的概率被看到。我会给与答案/评论一样多的投票,以支持Richard Forrest的R中的数字:
ARRRRRRRRRRRR