I know that if you run:
rundll32.exe desk.cpl,InstallScreenSaver toasters.scr
you can set the screensaver to toasters.scr
but it also opens up the screensaver configuration dialog. Is there a way to set the screensaver on Windows without opening any dialog by running a command?
You can also open screen saver setting from command prompt in Windows 10, here's how: Bring up the Run box by pressing the Windows key + R. Type the command control desk. cpl,,@screensaver and hit Enter.
Right-click on the desktop, choose Personalize, and then click on Screen Saver on the bottom right-hand side of the window.
I have found two ways to do it:
1) Add in registry, make sure is active and setTimeOut (only minutes)
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v SCRNSAVE.EXE /t REG_SZ /d C:\Windows\System32\Mystify.scr /f
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveActive /t REG_SZ /d 1 /f
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveTimeOut /t REG_SZ /d 60 /f
setScreenSaver(true, 1, "C:\\Windows\\System32\\Mystify.scr");
/**
* set screen saver active, timeout and scr, only works in Windows
* @param isActive
* @param timeOutMin only minutes
* @param pathToScr path to scr
* @throws IOException
*/
public static void setScreenSaver(boolean isActive, int timeOutMin, String pathToScr) throws IOException{
String _isActive = isActive ? "1" : "0";
//only works with minutes, min. 1 min
String _timeOut = timeOutMin > 1 ? timeOutMin*60+"" : "60";
Runtime.getRuntime().exec(new String[] { "reg", "add", "HKEY_CURRENT_USER\\Control Panel\\Desktop", "/v", "SCRNSAVE.EXE", "/t", "REG_SZ", "/d", pathToScr,"/f" });
Runtime.getRuntime().exec(new String[] { "reg", "add", "HKEY_CURRENT_USER\\Control Panel\\Desktop", "/v", "ScreenSaveActive", "/t", "REG_SZ", "/d", _isActive,"/f" });
Runtime.getRuntime().exec(new String[] { "reg", "add", "HKEY_CURRENT_USER\\Control Panel\\Desktop", "/v", "ScreenSaveTimeOut", "/t", "REG_SZ", "/d", _timeOut,"/f" });
}
2) Get path from registry and rewrite scr file, but if is set to null, you can't do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With