就像我說的,這個代碼在PowerShell中2版本,但不是在PowerShell中的版本5如何配置讀主機超時在PowerShell中
function wait
{
$compte = 0
Write-Host "To continue installation and ignore configuration warnings type [y], type any key to abort"
While(-not $Host.UI.RawUI.KeyAvailable -and ($compte -le 20))
{
$compte++
Start-Sleep -s 1
}
if ($compte -ge 20)
{
Write-Host "Installation aborted..."
break
}
else
{
$key = $host.ui.rawui.readkey("NoEcho,IncludeKeyup")
}
if ($key.character -eq "y")
{Write-Host "Ignoring configuration warnings..."}
else
{Write-Host "Installation aborted..."
}}
我需要像這樣:echo -n「要繼續安裝和配置無視警告鍵入[是],輸入任意鍵退出(安裝後會自動後20秒超時)中止:「 讀-t 20 RESP –