Skip to content

Instantly share code, notes, and snippets.

@prayagupa
Created November 1, 2022 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prayagupa/3dd220063f7c12fd35425defd627df98 to your computer and use it in GitHub Desktop.
Save prayagupa/3dd220063f7c12fd35425defd627df98 to your computer and use it in GitHub Desktop.
powershell, awake
clear host
# https://cloudrun.co.uk/powershell/how-to-keep-your-screen-alive-or-pc-from-going-to-sleep-during-presentations/
# Script to keep the PC alive, will prevent screen lock and sleep.
# Works by pressing Print Screen every 2 minutes, side effect is that a screenshot will overwrite the clipboard contents
#
write-warning "I am out for lunch."
Do {
[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.SendKeys]::SendWait("{F1}")
Start-Sleep -Seconds 120
} While ($true)
powershell.exe -ExecutionPolicy Bypass -File .\keep-alive.ps1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment