Oct
30
lineMy script is finally finished. Nobody else has created a script like this, and I wonder why not? There are plenty of system builders out there: small shops, OEM builders, etc etc etc. You would think they would like a script like this? I digress. This script will set your background based on your current aspect ratio, as well as set your OEM information.
::Beginning of file Install.bat :::::::::::: :: Script by Hans Kokx, 2007, skipmeister123[at]gmail.com :: Please give credit where credit is due. :: Portions of this script adapted from a script written by Rob van der Woude, http://www.robvanderwoude.com :: {Hans Kokx} Thank you Rob! :: This script will detect your current screen resolution, and moreso, your current aspect ratio. :: Using that information, it will set a different background for your aspect ratio, as well as set your OEM branding information... automatically. @ECHO OFF :: NOTE! Wallpapers must be in a .bmp format. Using a JPEG will result in a black (or solid colored) background, and no image. :::::::::::: :: Set background file variables. Change these variables to reflect your background file names. :::::::::::: :: By default, the background files are stored in a subfolder of this script, called 'files' ::::::::::: SET standardbg=standard.bmp SET widescreenbg=widescreen.bmp :: Enable variable expansion :::::::::::: SETLOCAL ENABLEDELAYEDEXPANSION CALL :quiet>NUL 2>&1 :: Let's set some variables for determining the aspect ratio :::::::::::: SET xres= SET yres= SET aspect= SET ratio= :DisplayX :: Search the registry tree for the X resolution value :::::::::::: SET Key=HKCC\System\CurrentControlSet\Control\VIDEO FOR /F "skip=5 tokens=*" %%A IN ('REG QUERY "%Key%"') DO ( FOR /F "skip=5 tokens=*" %%B IN ('REG QUERY "%%~A"') DO ( FOR %%C IN ("XResolution") DO ( FOR /F "skip=4 tokens=*" %%D IN ('REG QUERY "%%~B" /v DefaultSettings.%%C') DO ( CALL :DisplayXval %%D ) ) ) ) SET Key= SET Val= GOTO:DisplayY :DisplayXval :: Convert hexadecimal values to decimal :::::::::::: SET /A x = %3 :: Check and see if the X resolution is 800 (default safe mode resolution) and discard it. :::::::::::: IF NOT %x%==800 GOTO else GOTO endif :ELSE :: If the resolution is not a safe mode resolution, write it to a variable for later processing. :::::::::::: FOR /F "tokens=2 delims=." %%a IN ('ECHO.%1') DO ( SET xres=%x% ) :ENDIF GOTO:EOF :DisplayY :: Search the registry tree for the Y resolution value :::::::::::: SET Key=HKCC\System\CurrentControlSet\Control\VIDEO FOR /F "skip=5 tokens=*" %%A IN ('REG QUERY "%Key%"') DO ( FOR /F "skip=5 tokens=*" %%B IN ('REG QUERY "%%~A"') DO ( FOR %%C IN ("YResolution") DO ( FOR /F "skip=4 tokens=*" %%D IN ('REG QUERY "%%~B" /v DefaultSettings.%%C') DO ( CALL :DisplayYval %%D ) ) ) ) GOTO:Aspect :DisplayYval :: Convert hexadecimal values to decimal :::::::::::: SET /A y = %3 :: Check and see if the Y resolution is 600 (default safe mode resolution) and discard it. :::::::::::: IF NOT %y%==600 GOTO else GOTO endif :ELSE :: If the resolution is not a safe mode resolution, write it to a variable for later processing. :::::::::::: FOR /F "tokens=2 delims=." %%a IN ('ECHO.%1') DO ( SET yres=%y% ) :ENDIF GOTO:EOF :Aspect :: Calculate the aspect ratio based on the X and Y resolutions :::::::::::: SET /A ratio = (%xres%*100)/(%yres%) IF NOT %ratio% LEQ 150 GOTO else SET aspect=standard GOTO endif :ELSE SET aspect=widescreen :ENDIF GOTO:copy :copy ::Copy Wallpapers to the Windows directory :::::::::::: ECHO Copying wallpapers to %SystemRoot%... copy "files\%standardbg%" "%SystemRoot%\%standardbg%" copy "files\%widescreenbg%" "%SystemRoot%\%widescreenbg%" ECHO. :: Set wallpaper based on screen aspect ratio :::::::::::: IF NOT .%aspect%==.standard GOTO else ECHO Setting the the wallpaper for a standard aspect ratio... :: Configure Wallpaper for standard aspect ratio :::::::::::: REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "%SystemRoot%\%standardbg%" ECHO. ECHO Making sure the wallpaper is scaled... REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D 2 ECHO. GOTO endif :else ECHO Setting the the wallpaper for a widescreen aspect ratio. :: Configure Wallpaper for widescreen aspect ratio :::::::::::: REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "%SystemRoot%\%widescreenbg%" ECHO. ECHO Making sure the wallpaper is scaled... REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D 2 ECHO. :endif :: Make the changes effective immediately :::::::::::: %SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters ::Set the OEM Logo and information ::::::::::: :: Let's check and see which OS we're running, since setting OEM information on a legacy OS is a bit different. :::::::::::: :: Win9x checks :::::::::::: VER |find /i "Windows 95">NUL IF NOT ERRORLEVEL 1 GOTO W9598ME VER |find /i "Windows 98">NUL IF NOT ERRORLEVEL 1 GOTO W9598ME VER |find /i "Windows Millennium">NUL IF NOT ERRORLEVEL 1 GOTO W9598ME :: NT/XP checks :::::::::::: VER | find "XP"> nul IF %errorlevel% EQU 0 GOTO s_win_XP VER | find "2000"> nul IF %errorlevel% EQU 0 GOTO s_win_2000 VER | find "NT"> nul IF %errorlevel% EQU 0 GOTO s_win_NT ECHO Unknown OS ! GOTO :EOF :: Set the OEM information for Win9x :::::::::::: :W9598ME ECHO Setting OEM information (Legacy, Win9x)... copy files\oeminfo.ini %SystemRoot%\system copy files\oemlogo.bmp %SystemRoot%system GOTO cleanup :W98 ECHO Setting OEM information (Legacy, Win9x)... copy files\oeminfo.ini %SystemRoot%\system copy files\oemlogo.bmp %SystemRoot%system GOTO cleanup :: Set the OEM information for NT/2K/XP :::::::::::: :s_win_XP ECHO Setting OEM information... copy files\oeminfo.ini %SystemRoot%\system32 copy files\oemlogo.bmp %SystemRoot%\system32 GOTO cleanup :s_win_2000 ECHO Setting OEM information... copy files\oeminfo.ini %SystemRoot%\system32 copy files\oemlogo.bmp %SystemRoot%\system32 GOTO cleanup :s_win_NT ECHO Setting OEM information... copy files\oeminfo.ini %SystemRoot%\system32 copy files\oemlogo.bmp %SystemRoot%\system32 GOTO cleanup :cleanup :: Pause for a moment to verify :::::::::::: :: You could add calls to additional batch files or programs here. ::::::::::: ECHO. ECHO Finished. Please verify output and PAUSE GOTO:EOF :EOF :: End of file Install.bat :::::::::::
Additionally, I have written two more scripts. The first one prompts you for your aspect ratio, just in case you haven’t set the screen resolution yet
:: Beginning of file "Install (prompt).bat" ::::::::::: :: Script by Hans Kokx, 2007, skipmeister123[at]gmail.com :: Please give credit where credit is due. :: Portions of this script adapted from a script written by Rob van der Woude, http://www.robvanderwoude.com :: {Hans Kokx} Thank you Rob! :: This script will prompt the user to select which aspect ratio they are using, and set a wallpaper based on the selection. Additionally, it will set your OEM branding information. ::::::::::: @ECHO OFF :: NOTE! Wallpapers must be in a .bmp format. Using a JPEG will result in a black (or solid colored) background, and no image. :::::::::::: :: Set background file variables. Change these variables to reflect your background file names. :::::::::::: :: By default, the background files are stored in a subfolder of this script, called ‘files’ ::::::::::: SET standardbg=standard.bmp SET widescreenbg=widescreen.bmp :: Enable variable expansion :::::::::::: SETLOCAL ENABLEDELAYEDEXPANSION CALL :quiet>NUL 2>&1 ::Prompt for aspect ratio :::::::::::: ECHO “[S]tandard, [W]idescreen, or [Q]uit?” ECHO Enter your selection: SET /p aspect= ::Check to see whether the user wants to Quit, otherwise continue :::::::::::: IF NOT .%aspect%==.q GOTO copy GOTO quit :copy ::Copy Wallpapers to the Windows directory :::::::::::: ECHO %standardbg% - “files\%standardbg%” - “%SystemRoot%\%standardbg%” ECHO %widescreenbg% - “files\%widescreenbg%” - “%SystemRoot%\%widescreenbg%” PAUSE ECHO Copying wallpapers to %SystemRoot%… copy “files\%standardbg%” “%SystemRoot%\%standardbg%” copy “files\%widescreenbg%” “%SystemRoot%\%widescreenbg%” ::Set wallpaper based on selected aspect ratio :::::::::::: IF NOT .%aspect%==.s GOTO else echo Setting the wallpaper for a standard aspect ratio… :: Configure Wallpaper for standard aspect ratio :::::::::::: ECHO Adding the wallpaper entry to the registry… REG ADD “HKCU\Control Panel\Desktop” /V Wallpaper /T REG_SZ /F /D “%SystemRoot%\%standardbg%” ECHO Setting the wallpaper style in the registry… REG ADD “HKCU\Control Panel\Desktop” /V WallpaperStyle /T REG_SZ /F /D 2 ECHO Success! GOTO endif :else ECHO Setting the wallpaper for a widescreen aspect ratio… :: Configure Wallpaper for widescreen aspect ratio :::::::::::: REG ADD “HKCU\Control Panel\Desktop” /V Wallpaper /T REG_SZ /F /D “%SystemRoot%\%widescreenbg%” REG ADD “HKCU\Control Panel\Desktop” /V WallpaperStyle /T REG_SZ /F /D 2 ECHO Success! :endif :: Make the changes effective immediately :::::::::::: %SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters ::Set the OEM Logo and information :: Win9x checks :::::::::::: VER |find /i “Windows 95″ >NUL IF NOT ERRORLEVEL 1 GOTO W9598ME VER |find /i “Windows 98″ >NUL IF NOT ERRORLEVEL 1 GOTO W9598ME VER |find /i “Windows Millennium” >NUL IF NOT ERRORLEVEL 1 GOTO W9598ME :: NT/XP checks :::::::::::: VER | find “XP” > nul IF %errorlevel% EQU 0 GOTO s_win_XP VER | find “2000″ > nul IF %errorlevel% EQU 0 GOTO s_win_2000 VER | find “NT” > nul IF %errorlevel% EQU 0 GOTO s_win_NT ECHO Unknown OS ! GOTO :EOF :: Set the OEM information for Win9x :::::::::::: :W9598ME ECHO Setting OEM information (Legacy, Win9x)… copy files\oeminfo.ini %SystemRoot%\system copy files\oemlogo.bmp %SystemRoot%system GOTO cleanup :W98 ECHO Setting OEM information (Legacy, Win9x)… copy files\oeminfo.ini %SystemRoot%\system copy files\oemlogo.bmp %SystemRoot%system GOTO cleanup :: Set the OEM information for NT/2K/XP :::::::::::: :s_win_XP ECHO Setting OEM information… copy files\oeminfo.ini %SystemRoot%\system32 copy files\oemlogo.bmp %SystemRoot%\system32 GOTO cleanup :s_win_2000 ECHO Setting OEM information… copy files\oeminfo.ini %SystemRoot%\system32 copy files\oemlogo.bmp %SystemRoot%\system32 GOTO cleanup :s_win_NT ECHO Setting OEM information… copy files\oeminfo.ini %SystemRoot%\system32 copy files\oemlogo.bmp %SystemRoot%\system32 GOTO cleanup ECHO Logo set successfully. :cleanup :: Pause for a moment to verify :::::::::::: ECHO Finished. Please verify output and PAUSE GOTO:EOF :quit ECHO Operation aborted by user. No changes have been made to the system. PAUSE :EOF :: End of file "Install (prompt).bat" ::::::::::
And finally, a script to remove the OEM branding and custom backgrounds
:: Beginning of file "Remove branding.bat" ::::::::::: :: Script by Hans Kokx, 2007, skipmeister123[at]gmail.com :: Please give credit where credit is due. @ECHO OFF :: Set background file variables. Change these variables to reflect your background file names. :::::::::::: :: These are the same variables you should have set in Install.bat :::::::::::: SET standardbg=standard.bmp SET widescreenbg=widescreen.bmp :: Confirm removal of branding information :::::::::::: ECHO You are about to remove OEM branding information and custom wallpapers from this system. ECHO Continue? [y/n] SET /p continue= :: Simple if/then statement to decide what to do next. :::::::::::: IF NOT .%continue%==.n GOTO remove GOTO:quit :remove :: Remove the OEM logo and information files, and the custom backgrounds :::::::::::: DEL “%systemroot%\system32\oeminfo.ini” DEL “%systemroot%\system32\oemlogo.bmp” DEL “%systemroot%\%standardbg%” DEL “%systemroot%\%widescreenbg%” :: Make the changes effective immediately :::::::::::: %SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters GOTO endif :else ECHO Removal cancelled by user. GOTO:quit :endif :quit ECHO Finished. PAUSE :: End of file "Remove branding.bat" ::::::::::
The files needed for these scripts will be located in \files and are two background files (widescreen and standard), both in BMP format. JPG will not work, and will give you a plain colored background instead. You will also need oeminfo.ini and oemlogo.bmp. Your oemlogo.bmp file should be 150px by 80px. Your oeminfo.ini file should look similar to the code below
[Beginning of file oeminfo.ini] [General] Manufacturer=Your company name here Model=Your computer model here SupportURL=http://www.yourwebsite.com [Support Information] Line1=This can be Line2=anything that Line3=you want Line4=it to be. Line5=It can be as many lines as you’d like it to be. [End of file oeminfo.ini]
Here is what your file structure should look like:
Root/
├───Install (prompt).bat
├───Install.bat
├───Remove branding.bat
├───Files.ini
└───files/
├───oemlogo.bmp
├───standard.bmp
└───widescreen.bmp
You must be logged in to post a comment.