title: Windows batch script to switch desktop background
body: <p>Is there a way to check what a user currently has as their background and then changing it depending on what it is?  For example:  I want a white background during day time and a black background for night time.  Running the script would check the current background, if it is white it will switch to the black background, and if it is black it will switch to the white.</p>
  
  <p>I'm a little unfamiliar with Windows batch script and I'm seeking some tips and advice on how I can accomplish the task above.  Here is what I've been able to find so far:</p>
  
  <pre><code>@echo off
  call :quiet&gt;nul 2&gt;&amp;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
  </code></pre>