Waiting for user input with a timeout

后端 未结 4 1428
北海茫月
北海茫月 2020-11-28 15:36

I have searched but apparently my google foo is weak. What I need is a way to prompt for user input in the console and have the request time out after a period of time and c

4条回答
  •  醉话见心
    2020-11-28 16:07

    Found something here:

    $counter = 0
    while(!$Host.UI.RawUI.KeyAvailable -and ($counter++ -lt 600))
    {
          [Threading.Thread]::Sleep( 1000 )
    }
    

提交回复
热议问题