Whenever I set a delay in powershell using Start-Sleep
, e.g:
Start-Sleep 10
then it does not ignore CTRLC. I mean when I hit that key stroke the delay quits. How can I ignore it in delays?
You can temporarily set [Console]::TreatControlCAsInput
to $true
:
[Console]::TreatControlCAsInput = $true
Start-Sleep 10 # Ctrl-C will now not abort this sleep.
[Console]::TreatControlCAsInput = $false