Disable screen saver with Powershell

Is there a way turn off my Windows 7 screen saver using a Powershell script?
LesterJebsonAsked:
Who is Participating?
 
Meir RivkinFull stack Software EngineerCommented:
set-item -path 'HKCU:\Control Panel\Desktop\ScreenSaveActive' -value 0

Open in new window

you will need to reboot the machine to apply changes
1
 
LesterJebsonAuthor Commented:
Sedgwick,

This looks very close but it's giving me an error when I try to run it.  Is the syntax above correct?

Set-Item : The registry key at the specified path does not exist.
At C:\Temp\FixScreenSaver.ps1:1 char:9
+ set-item <<<<  -path 'HKCU:\Control Panel\Desktop\ScreenSaveActive' -value 0
    + CategoryInfo          : InvalidArgument: (HKEY_CURRENT_US...creenSaveActive:String) [Set-Item], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.SetItemCommand

Thank you
0
 
LesterJebsonAuthor Commented:
Sedgwick,

Thank you so much!  I slightly modified your example and it worked great.  This Powershell command turns off the screen saver.

set-ItemProperty -path 'HKCU:\Control Panel\Desktop' -name ScreenSaveActive -value 0
0
 
LesterJebsonAuthor Commented:
Thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.