Use a Powershell script to take and save screenshots in the background. The script is called via the Windows Task Scheduler.

This example uses Windows 10, so change your targets as appropriate.

Screenshot Function and Script

Create a new script named screenshot.ps1. Insert the following and save it. Change the filename path to match your needs.

screenshot.ps1
Add-Type -AssemblyName System.Windows.Forms
[Reflection.Assembly]::LoadWithPartialName("System.Drawing")
function screenshot([Drawing.Rectangle]$bounds, $path) {
   $bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height
   $graphics = [Drawing.Graphics]::FromImage($bmp)

   $graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)

   $bmp.Save($path)

   $graphics.Dispose()
   $bmp.Dispose()
}

While($True){

    $width = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width
    $height = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height
    $bounds = [Drawing.Rectangle]::FromLTRB(0, 0, $width, $height)

    $timestamp = get-date -Format ddMMyhhmmss
    $filename = "C:\bin\screenshot" + $timestamp + ".jpg"

    screenshot $bounds $filename

    $sleeptime = 900
    Start-Sleep
}

A few items to change to match your environment and needs are:

  • $filename, change to C:\bin\screenshot to your chosen path

  • $sleeptime, change to number of seconds between screenshots

Sign your Script

  • Start Powershell as a user

  • $cert = @(Get-ChildItem cert:\CurrentUser\My -codesigning)[0]

  • Set-AuthenticodeSignature screenshot.ps1 $cert

Test Run

  • For testing, I set $sleeptime = 5

  • Run command, using WindowsKey + r

  • powershell -windowstyle hidden \bin\screenshot.ps1

    • Substitute \bin\screenshot.ps1 with your path

  • Verify that screenshots are saved to your chosen $filename

  • Kill the powershell script using Task Manager

    • Task Manager shortcut is Ctrl+Shift+Esc

    • In the Processes tab under the Background processes select Windows Powershell

    • Click End task

Task Scheduler

Open

  • Launch Task Scheduler

    • Search via WindowsKey + s

    • Start typing task, usually enough

    • Click Task Scheduler

Create Task

  • Click Create Task

  • On the General tab, give the task a name

  • On the Triggers tab, click New

    • Begin the task At log on for Any user

    • Click Ok

  • On the Actions tab, click New

    • Action is Start a program

    • Program/script is powershell

    • Add arguments is -windowstyle hidden \bin\screenshot.ps1

    • Click Ok

  • Click Ok

The task has been added and will run at the next and every log on. Review the other settings available in Task Scheduler to make certain the task runs as you require it. The Screenshot script does not need to be run multiple times as it continues to run in the background while it sleeps.

Resources