Stop currently running Windows screensaver from command line

8,380

Solution 1

I had a eureka moment, I was making the approach too complex. All that's needed is:

kill -processname XXXX

Where XXXX is the name of the screensaver process

Solution 2

You can do this using PowerShell to move the mouse a pixel, deactivating the screensaver.

$Pos = [System.Windows.Forms.Cursor]::Position
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point((($Pos.X) + 1) , $Pos.Y)

You can also try a 3rd party program, such as AutoIt, which allows you to script mouse movements.

Solution 3

The correct syntax would be:

taskkill /im PhotoScreensaver.scr /f

With of course the correct name of the running screensaver, which in my case is PhotoScreensaver.scr

Share:
8,380

Related videos on Youtube

Peter Bridger
Author by

Peter Bridger

Lead Developer at Sparkol (www.sparkol.com) instiling the benefits of TDD and SOLID within the teams I run and using Scrum and a Continuous Delivery pipeline to continuously deliver high quality software

Updated on September 18, 2022

Comments

  • Peter Bridger
    Peter Bridger almost 2 years

    I have a number of Scheduled Tasks running on a Windows machine, which is design to run stand alone and show useful information to the office.

    Part of it's use is to run a screensaver that itself shows useful information.

    There are some scheduled tasks which need to display information to the screen, however as the screensaver is running these messages can't be seen until the screensaver it manually deactivated.

    How can the currently running screensaver in Windows be deactivated from command script?

    • matan129
      matan129 almost 11 years
      Just clear this to me. The new screensaver won't show up because there is already one running?
    • gronostaj
      gronostaj almost 11 years
      What about "pressing spacebar" programmatically?
    • Werner Henze
      Werner Henze almost 11 years
      What are these tasks? Programs programmed by you?
    • Peter Bridger
      Peter Bridger almost 11 years
      Yes, they're written by me
  • Peter Bridger
    Peter Bridger almost 11 years
    Unfortunately the simulated mouse approach didn't work :(
  • Werner Henze
    Werner Henze almost 11 years
    Definitely not elegant, especially if the tasks are programs written by yourself.