Using Powershell to make your screensaver never lock


The following script simply toggles the SCROLL-LOCK key every 4 minutes with a .1s double click.

To use: save this as a Powershell script (ending with .ps1) and then run it. Once open, just minimize the script window. It'll still run fine minimized.

Echo "Keep alive with scroll lock"
$WShell = New-Object -com ""
while ($True)
  start-sleep -Milliseconds 100
  start-sleep -Seconds 240

An alternative script I wrote gives more detail. I have it pressing the Num Lock Key on a random schedule from 0 to 30 minutes.

Echo "Keep alive with NUMLOCK"
$WShell = New-Object -com ""
while ($True)
  $rand=Get-Random -Maximum 1800
  $ts = New-TimeSpan -Seconds $rand
  Write-Host  "$([math]::Round($randminutes,2)) Minutes Start($(Get-Date)) End($((Get-Date)+$ts))"  
  start-sleep -Seconds $rand


Share on Google Plus

About Tom DeMeulenaere

Highly accomplished information technology professional with extensive knowledge in System Center Configuration Manager, Windows Server, SharePoint, and Office 365.
    Blogger Comment


Post a Comment

Note: Only a member of this blog may post a comment.