Thursday, July 7, 2016

Preventing Screen Saver with PowerShell

Here's a short bit of PowerShell you can have run when you log in to a machine (or manually)...
Function Prevent-ScreenSaver
{
    [CmdletBinding()]
    Param(
        [int]$IntervalSeconds = 60,
        [string]$KeyToSend = "{F15}"
    )
    $Shell = New-Object -COM “WScript.Shell”
    While ($True)
    {
        Write-Verbose "Sending key '$KeyToSend'..."
        $Shell.SendKeys($KeyToSend)
     
        Write-Verbose "`t...waiting $IntervalSeconds seconds..."
     
        Start-Sleep $IntervalSeconds
    }
}

Save that to a file, then have it start on login (via shortcut in Startup folder)...





Inspired by: https://dmitrysotnikov.wordpress.com/2009/06/29/prevent-desktop-lock-or-screensaver-with-powershell/

There's an alternative little utility, called Screen Slayer. As of 7/7/2016, links and info can be found here: http://daniel-lange.com/archives/34-Disabling-a-group-policyd-screensaver-on-Windows.html


No comments: