gpt4 book ai didi

windows - 从命令行在 Windows 上静默设置屏幕保护程序?

转载 作者:可可西里 更新时间:2023-11-01 13:28:42 29 4
gpt4 key购买 nike

我知道如果你跑:

rundll32.exe desk.cpl,InstallScreenSaver toasters.scr

您可以将屏幕保护程序设置为 toasters.scr,但它也会打开屏幕保护程序配置对话框。有没有办法通过运行命令在 Windows 上设置屏幕保护程序而无需打开任何对话框?

最佳答案

我找到了两种方法:

1)在注册表中添加,确保处于事件状态并设置TimeOut(仅分钟)

命令

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

Java

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) 从注册表中获取路径并重写scr文件,但如果设置为null,则无法执行。

关于windows - 从命令行在 Windows 上静默设置屏幕保护程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49791065/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com