Powershell-创建自定义windows服务以模拟
为了模拟以下代码,我的问题是:我想使用powershell创建名为DelayedService的假延迟windows服务。所以我不希望它立即进入运行状态 这是我的剧本:Powershell-创建自定义windows服务以模拟,powershell,Powershell,为了模拟以下代码,我的问题是:我想使用powershell创建名为DelayedService的假延迟windows服务。所以我不希望它立即进入运行状态 这是我的剧本: $ServiceName = 'DelayedService' # obviously to test... $arrService = Get-Service -Name $ServiceName $TimeOut = 20 $count = 0 Start-Service $ServiceName :SrvCheck wh
$ServiceName = 'DelayedService' # obviously to test...
$arrService = Get-Service -Name $ServiceName
$TimeOut = 20
$count = 0
Start-Service $ServiceName
:SrvCheck while ( $arrService.Status -ne 'Running' )
{
$arrService.Refresh()
if ($arrService.Status -eq 'Running' -or $Count -ge $timeout)
{
Write-Host 'Service is now Running'
Break SrvCheck
}
write-host "Waiting for service start, Current Status $($arrService.status) ..."
Start-Sleep -seconds 3
++$count
}
谢谢,这个问题似乎不完整:我无法从标题中理解您试图模拟什么,也无法通过阅读问题理解您的阻碍点。你能看一下吗?哇,谢谢你的帮助@MathiasR.Jessen