@ECHO OFF :: Check Windows version IF NOT "%OS%"=="Windows_NT" GOTO Syntax :: Check number of command line arguments IF "%~1"=="" GOTO Syntax IF NOT "%~2"=="" GOTO Syntax :: Check if invalid characters were used ECHO.%* | FIND "/" > NUL && GOTO Syntax ECHO.%* | FIND "?" > NUL && GOTO Syntax ECHO.%* | FIND "*" > NUL && GOTO Syntax :: Get the fully qualified path and check if the file exists PUSHD %windir% IF NOT EXIST "%~1" GOTO Syntax DIR /A-D "%~1" >NUL 2>&1 || GOTO Syntax SET WallPaper=%~f1 POPD :: Escape backslashes for the temporary .REG file SET WallPaper=%WallPaper:\=\\% :: Create a temporary .REG file to change the Wallpaper setting > "%Temp%.\wallpaper.reg" ECHO REGEDIT4 >> "%Temp%.\wallpaper.reg" ECHO. >> "%Temp%.\wallpaper.reg" ECHO [HKEY_CURRENT_USER\Control Panel\Desktop] >> "%Temp%.\wallpaper.reg" ECHO "Wallpaper"="%WallPaper%" >> "%Temp%.\wallpaper.reg" ECHO. :: Merge the temporary file to change the Wallpaper setting in the registry START /WAIT REGEDIT.EXE /S "%Temp%.\wallpaper.reg" :: Activate the changes; thanks for Pete Smith for this RUNDLL32 command :: RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1 True :: Clean up SET WallPaper= DEL "%Temp%.\wallpaper.reg" :: Done GOTO:EOF :Syntax ECHO. ECHO SetWallp.bat, Version 1.00 for Windows 2000 and later ECHO Set a specified bitmap as Windows' wallpaper. ECHO Based on a RUNDLL32 command by Pete Smith. ECHO. ECHO Usage: SETWALLP bitmap ECHO. ECHO Where: "bitmap" is the bitmap file ECHO (or the fully qualified path if not located in %windir%) ECHO. ECHO Written by Rob van der Woude ECHO http://www.robvanderwoude.com