PowerShell script to suspend Windows screensaver at specific locations

Say that you are working with two laptops side by side. You may not like the automatic screensaver kicking in on a laptop while you are momentarily working on the other, in particular if it requires a password to unlock. This may be especially true at certain locations that are trusted (e.g. home).

The following PowerShell script for Windows can be used for suspending the screensaver when you are connected to a specific Wi-Fi network.

$wsh = New-Object -ComObject WScript.Shell
# Idea to use WSH comes from: https://stackoverflow.com/questions/9794893/powershell-toggle-num-lock-on-and-off

while ($true) {
  $wifi = get-netconnectionprofile | Out-String -Stream | Select-String -Pattern ""
  if ($wifi) {
    $wsh.SendKeys('+')
  }
  Start-Sleep -Seconds 60
}

no responses for PowerShell script to suspend Windows screensaver at specific locations

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.