Windows批处理脚本切换桌面背景

有没有办法来检查用户目前有什么作为他们的背景,然后改变它取决于它是什么? 例如:我想白天的时候是白色背景,晚上是黑色的背景。 运行脚本将检查当前的背景,如果是白色,则会切换到黑色背景,如果是黑色,则会切换到白色。

我有点不熟悉Windows批处理脚本,我正在寻求一些关于如何完成上述任务的提示和build议。 这是我迄今为止能够find的东西:

@echo off call :quiet>nul 2>&1 goto :EOF :quiet :: Configure Wallpaper REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "%SystemRoot%\energybliss.bmp" REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D 0 REG ADD "HKCU\Control Panel\Desktop" /V TileWallpaper /T REG_SZ /F /D 2 :: Configure the screen saver. :: REG ADD "HKCU\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\scrnsave.scr" :: REG ADD "HKCU\Control Panel\Desktop" /V ScreenSaveActive /T REG_SZ /F /D 1 :: Set the time out to 900 seconds (15 minutes). :: REG ADD "HKCU\Control Panel\Desktop" /V ScreenSaveTimeOut /T REG_SZ /F /D 900 :: Set the On resume, password protect box :: REG ADD "HKCU\Control Panel\Desktop" /V ScreenSaverIsSecure /T REG_SZ /F /D 1 :: Remove the user's ability to see the Screen Saver, background, and appearance tabs of Display Properties. ::REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /V NoDispScrSavPage /T REG_DWORD /F /D 1 ::REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /V NoDispBackgroundPage /T REG_DWORD /F /D 1 ::REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /V NoDispAppearancePage /T REG_DWORD /F /D 1 :: Make the changes effective immediately %SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters 

Solutions Collecting From Web of "Windows批处理脚本切换桌面背景"

你可以使用这样的代码:

 @echo off :: '>nul 2>&1' was moved to other place call :quiet exit /b :quiet :: Put there wallpaper name (with extension, bigger that 8 symbols) set "Wallpaper.Night.BadWrited=Wallpaper1.bmp" :: It is a dirty hack and example of bad code for /F "tokens=*" %%a in ('reg query "HKCU\Control Panel\Desktop" /v Wallpaper') do set "Wallpaper.Current.BadWrited=%%a" :: Take last 8 symbols of wallpaper name. Change number of symbols to your own minimal set "Wallpaper.Current.BadWrited=%Wallpaper.Current.BadWrited:~-8%" set "Wallpaper.Night.BadWrited=%Wallpaper.Night.BadWrited:~-8%" if "%Wallpaper.Current.BadWrited%"=="%Wallpaper.Night.BadWrited%" ( call :MakeDayWallpaper>nul 2>&1 ) else ( call :MakeNightWallpaper>nul 2>&1 ) exit /b :MakeDayWallpaper echo Day wallpaper setted :: Put your code here exit /b :MakeNightWallpaper echo Night wallpaper setted :: Put your code here exit /b 

但我建议使用系统调度程序。 您可以从控制面板,“计划任务”或其他东西访问它。 您可以创建两个名为“makeday.bat”和“makenight.bat”的文件。 调度程序将在需要的时候每天运行它们