oem logo backup batch

Discussion in 'Scripting' started by ndog, Oct 3, 2012.

  1. ndog

    ndog MDL Novice

    Jul 18, 2009
    22
    8
    0
    #1 ndog, Oct 3, 2012
    Last edited by a moderator: Apr 20, 2017
    As a system builder I get a lot of machines with factory pre loaded junk on them. I like to reinstall windows fresh. Using help from MDL I got information on how to reinstall the OEM license activation offline. This is simple as copying the slic cert into the OEM folder and sysprep figures out to make it activated offline.

    I couldn't find any info on the internet how to backup the OEM logo, OEM information, OEM welcome screen wallpaper via a batch file. I wanted to first backup the OEM wallpaper, OEM logo and OEM welcome screen background and stuff and then reapply it on the machine so it still looks like a factory setup. So I thought I would come up with my own batch to do backup and restore it.

    Please add improvements if you have any. I am only posting this to share with the community since I learnt a lot from MDL.

    backupoem.cmd
    Code:
    @echo off&cls
    
    rem Backup OEM 1.1 - ndog
    rem Welcome screen background, desktop background, SLIC cert, logo
    
    :: make appropriate folder
    set _mmb=HPOEM
    md "%_mmb%" 2>nul >nul
    
    :: Backup Welcome screen background
    echo d | xcopy "%windir%\system32\oobe\info" "%~dp0%_mmb%\oobe\info" /s/i/y
    reg export "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI" "%~dp0%_mmb%\oem-welcomescreenbackground.reg" /y
    
    :: Backup system properties logo and OEM information
    reg export "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" "%~dp0%_mmb%\oem-logoinformation.reg" /y
    for /f "tokens=3 delims= " %%g in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v "Logo" 2^>nul') do (set _logofile=%%g)
    if defined _logofile copy /y "%_logofile%" "%~dp0%_mmb%"
    
    :: Backup SLIC certs - if found
    for /f "tokens=*" %%g in ('dir /b "%windir%\system32\oem\*.xrm-ms" 2^>nul') do (
    md "%~dp0%_mmb%\oem" 2>nul >nul
    copy "%windir%\system32\oem\%%g" "%~dp0%_mmb%\oem"
    )
    
    :: Backup desktop background - if found
    if exist "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg" copy /y "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg" "%~dp0%_mmb%\oem-desktopwallpaper.jpg"
    if exist "%LOCALAPPDATA%\Microsoft\Wallpaper1.bmp" copy /y "%LOCALAPPDATA%\Microsoft\Wallpaper1.bmp" "%~dp0%_mmb%\oem-desktopwallpaper.bmp"
    
    ping localhost -n 8 >nul
    
    restoreoem.cmd
    Code:
    @echo off&cls
    
    rem Restore OEM 1.0 - ndog
    rem Installs welcome screen background, OEM logo and OEM information
    
    :: Choose appropriate folder
    set _mmb=HPOEM
    
    :: Restore Welcome screen background
    echo d | xcopy "%~dp0%_mmb%\oobe\info" "%windir%\system32\oobe\info" /s/i/y
    reg import "%~dp0%_mmb%\oem-welcomescreenbackground.reg"
    
    :: Restore system properties logo and OEM information
    reg import "%~dp0%_mmb%\oem-logoinformation.reg"
    for /f "tokens=3 delims= " %%g in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v "Logo" 2^>nul') do (
    set _logofilebackupfile=%%~nxg
    set _logofilerestorefull=%%g
    )
    if defined _logofilebackupfile (
    mkdir "%_logofilerestorefull%" 2>nul >nul
    rd /s/q "%_logofilerestorefull%" 2>nul >nul
    copy /y "%~dp0%_mmb%\%_logofilebackupfile%" "%_logofilerestorefull%"
    )
    
    :: Restore SLIC certs
    for /f "tokens=*" %%g in ('dir /b "%~dp0%_mmb%\oem\*.xrm-ms" 2^>nul') do (
    md "%windir%\system32\oem" 2>nul >nul
    copy "%~dp0%_mmb%\oem\%%g" "%windir%\system32\oem"
    )
    
    :: Apply desktop background to current user (recommend to do this part properly)
    REM if exist "%~dp0%_mmb%\oem-desktopwallpaper.jpg" copy /y "%~dp0%_mmb%\oem-desktopwallpaper.jpg" "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg"
    REM if exist "%~dp0%_mmb%\oem-desktopwallpaper.bmp" copy /y "%~dp0%_mmb%\oem-desktopwallpaper.bmp" "%LOCALAPPDATA%\Microsoft\Wallpaper1.bmp"
    
    ping localhost -n 8 >nul
    
     
  2. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    Just tryed it and i get erros unable to write to file?
     
  3. ndog

    ndog MDL Novice

    Jul 18, 2009
    22
    8
    0
    I tried it on 2 new machines today, Acer AOD 270 and HP Compaq Pro 4300 AiO, no problems. Just unboxed them, let them run through OOBE to desktop then ran backup script and all the OEM stuff was saved nicely. Then I reinstalled windows 7 from scratch and restored the OEM stuff using the restore script.
     
  4. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    #4 NICK@NUMBER11, Oct 3, 2012
    Last edited: Oct 3, 2012
    this is what i get when i run the batch file...

    Capture.jpg


    **edit**

    I see what i did not do you have to create a folder first before running this script.. it works perfectly now
     
  5. ndog

    ndog MDL Novice

    Jul 18, 2009
    22
    8
    0
    Ah ha! Good spot, have updated the script.
     
  6. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    Yep that works 100% - Sorted :rolleyes:
     
  7. ndog

    ndog MDL Novice

    Jul 18, 2009
    22
    8
    0
    Thanks for testing. I hope to get some more feedback from others. Also hopefully others can add improvements over time. :biggrin:
     
  8. Dos_Probie

    Dos_Probie MDL Senior Member

    Jul 18, 2012
    250
    86
    10
    #8 Dos_Probie, Oct 3, 2012
    Last edited by a moderator: Apr 20, 2017
    Ndog, not bad but your batch only works assuming the computer is in good working condition and able to capture the info (hard drive is in working condition etc) Also you could add User bmp and theme as well which could would be really easy.

    Here is how I do it when doing a unattended reinstall of Win7 off of a thumbdrive.. or you could do Post-Install as well..:)

    There is already a post on mdl of Multi_brand Oems and you can use those files then create off root of dvd or thumbdrive
    a WPI\Copy\OEM folders and in OEM would contain each of the major OEM Manf. ie Acer, Dell, Hewlett-Packard etc.

    Then use the following batch file and it will restore for you all the same things like your batch plus the user.bmp, theme and setup Internet Explorer back to manf. default page etc. You can do this as post install or run from setupcomplete and have it all pre-installed for you to save you time and and effort..

    From Setupcomplete.cmd Runonce: reg add %key%\098 /v 1 /d "%usb%\wpi\scripts\cmd\OEM.cmd" /f

    and my oem.cmd that I use is:
    Code:
    @echo off &setlocal enableDelayedExpansion
    :: DOS_Probie , based on script from Dostips.com
    :: Oem.cmd
    
    :: AUTO UNATTENDED OEM BRANDING FOR WINDOWS 7
    ::
    :: Set Variable Parameters
    set copy=xcopy /cqhysei
    set theme=rundll32.exe %SystemRoot%\system32\shell32.dll,Control_RunDLL %SystemRoot%\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:"%windir%\Resources\Themes
    set ping=ping -n 2 127.0.0.1>nul
    set taskill=taskkill /f /im explorer.exe>nul 2>&1
    set start=start explorer.exe>nul 2>&1
    set kill=wmic process where name="dllhost.exe" call terminate>nul
    ::
    :: Minimize
    min.exe
    
    :§init ( paramRAW )
    :: (
           mode con: cols=75 lines=20
           color 1e
           title [-OEM BRANDING FOR WINDOWS 7-]
    
           call :§main %* !
           cls
           echo.please test it before removing these lines ;^)
           :pause
    :: )
    exit /b 0
    
    :§main ( null )
    :: (
           :: Copy from Root of USB
    
           for %%? in (
    
                  d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s
    
           ) do   if exist "%%~?:\sources\install.wim" (
    
                  set "$usb.drive=%%~?:"
           )
    
           :: WMI OEM BIOS QUERY TO INPUT VARIABLE then CALL DATA - (Note:Add more OEMs as needed!)
    
           set "$manufacturer=custom" &for /f "skip=1 tokens=1" %%? in (
    
                  'wmic.exe bios get Manufacturer'
    
           ) do   set "$=%%~?" &for %%? in (
    
                  ACER, ASUS, COMPAQ, CUSTOM, DELL, EMACHINE, GATEWAY, Hewlett-Packard, SONY, TOSHIBA,
    
           ) do   if "!$!" neq "!$:%%~?=!" set "$manufacturer=%%~?"
    
           ::goto :CUSTOM
    
           :: OEM BRANDING
    
           regedit /s !$usb.drive!\wpi\copy\oem\!$manufacturer!\!$manufacturer!.REG
    ::    The <src-full-path> variable specifies the full directory path and name of the file that you want to copy from the USB drive.
    
           set "$src.fullPath=!$usb.drive!\wpi\copy\oem\!$manufacturer!"
           %copy% "!$src.fullPath!\WALLPAPER.jpg" "%windir%\web\wallpaper"
           %copy% "!$src.fullPath!\!$manufacturer!.THEME" "%windir%\resources\themes"
           %copy% "!$src.fullPath!\!$manufacturer!_BADGE.BMP" "%windir%\system32\oobe\info"
    
           %kill%
           :wmic.exe process where name="dllhost.exe" call terminate
    
           :: Set Theme
           %theme%\!$manufacturer!.Theme"
    
           :: Refresh Desktop
           %ping%
           %taskill%
           %start%
           goto :EOF
    
          : >nul 2>&1 ping -n 2 127.0.0.1
          : taskkill /f /im explorer.EXE
          : start "" "explorer.EXE"
           :: )
    
           ::CUSTOM
    
           :EOF
           exit /b 0
    
     
  9. Dos_Probie

    Dos_Probie MDL Senior Member

    Jul 18, 2012
    250
    86
    10
    #9 Dos_Probie, Oct 3, 2012
    Last edited by a moderator: Apr 20, 2017
    I put your code in a menu to consolidate everything, nulled out confirmations and added a few other twks..:D

    Code:
    @echo off&color e&mode con:cols=70 lines=18&title[ ~ OEM BACKUP AND RESTORE TOOL ~ ]
    setlocal enableextensions
    @cd /d "%~dp0"
    ::===========+
    :: OEM.Backup.Restore.cmd
    :: Backup.Restore OEM 1.1 - ndog
    :: Based on OEM 1.1 - ndog from: forums.mydigitallife.net/threads/37907-oem-logo-backup-batch
    ::===========+
    :MAINMENU
    cls
    echo            [MAIN MENU]
    echo      +=====================+  
    echo       A.) BACKUP OEM 
    echo.
    echo       B.) RESTORE OEM
    echo.
    echo       C.) COMPUTER Info
    echo.
    echo       D.) CHECK License
    echo.
    echo       E.) EXIT The Program
    echo      +=====================+ 
    echo.
    echo.
    set choice=
    set /p choice= When Ready Select: A, B, C, D, or E then press [ENTER]:
    echo.
    if not '%choice%'=='' set choice=%choice:~0,1%
    
    if /I '%choice%'=='A' goto BACKUP
    if /I '%choice%'=='B' goto RESTORE
    if /I '%choice%'=='C' goto INFO
    if /I '%choice%'=='D' goto License
    if /I '%choice%'=='E' goto EOF
    echo.
    echo "%choice%" Key is Incorrect!  Please Select Correct Key Then Try Again..
    echo.
    goto :mainmenu
    ::===========+
    :BACKUP
    cls &color e
    echo Press any [KEY] To Begin Backup ...&pause>nul&goto :bu
    :bu
    cls
    :: make appropriate folder
    set _mmb=HPOEM
    md "%_mmb%" 2>nul >nul
    
    :: Backup Welcome screen background
    echo d | xcopy "%windir%\system32\oobe\info" "%~dp0%_mmb%\oobe\info" /s/i/y>nul 2>&1
    reg export "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI" "%~dp0%_mmb%\oem-welcomescreenbackground.reg" /y>nul 2>&1
    
    :: Backup system properties logo and OEM information
    reg export "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" "%~dp0%_mmb%\oem-logoinformation.reg" /y>nul 2>&1
    for /f "tokens=3 delims= " %%g in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v "Logo" 2^>nul') do (set _logofile=%%g)
    if defined _logofile copy /y "%_logofile%" "%~dp0%_mmb%">nul 2>&1
    
    :: Backup SLIC certs - if found
    for /f "tokens=*" %%g in ('dir /b "%windir%\system32\oem\*.xrm-ms" 2^>nul') do (
        md "%~dp0%_mmb%\oem" 2>nul >nul
        copy "%windir%\system32\oem\%%g" "%~dp0%_mmb%\oem"
        )
    
    :: Backup desktop background - if found
    if exist "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg" copy /y "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg" "%~dp0%_mmb%\oem-desktopwallpaper.jpg">nul 2>&1
    if exist "%LOCALAPPDATA%\Microsoft\Wallpaper1.bmp" copy /y "%LOCALAPPDATA%\Microsoft\Wallpaper1.bmp" "%~dp0%_mmb%\oem-desktopwallpaper.bmp">nul 2>&1
    ping localhost -n 3 >nul
    echo.
    cls
    echo * DONE * == Press Any [KEY] To Return To The Main Menu ==&pause>nul&goto :mainmenu
    ::===========+
    :RESTORE  
    cls &color e
    echo Press any [KEY] To Begin Restore ...&pause>nul&goto :rs
    :rs
    cls
    :: Choose appropriate folder
    set _mmb=HPOEM
    
    :: Restore Welcome screen background
    echo d | xcopy "%~dp0%_mmb%\oobe\info" "%windir%\system32\oobe\info" /s/i/y>nul 2>&1
    reg import "%~dp0%_mmb%\oem-welcomescreenbackground.reg">nul 2>&1
    
    :: Restore system properties logo and OEM information
    reg import "%~dp0%_mmb%\oem-logoinformation.reg">nul 2>&1
    for /f "tokens=3 delims= " %%g in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation" /v "Logo" 2^>nul') do (
        set _logofilebackupfile=%%~nxg
        set _logofilerestorefull=%%g
        )
    if defined _logofilebackupfile (
        mkdir "%_logofilerestorefull%" 2>nul >nul
        rd /s/q "%_logofilerestorefull%" 2>nul >nul
        copy /y "%~dp0%_mmb%\%_logofilebackupfile%" "%_logofilerestorefull%">nul 2>&1
        )
    
    :: Restore SLIC certs
    for /f "tokens=*" %%g in ('dir /b "%~dp0%_mmb%\oem\*.xrm-ms" 2^>nul') do (
        md "%windir%\system32\oem" 2>nul >nul
        copy "%~dp0%_mmb%\oem\%%g" "%windir%\system32\oem">nul 2>&1
        )
    
    :: Apply desktop background to current user (recommend to do this part properly)
    REM if exist "%~dp0%_mmb%\oem-desktopwallpaper.jpg" copy /y "%~dp0%_mmb%\oem-desktopwallpaper.jpg" "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg">nul 2>&1
    REM if exist "%~dp0%_mmb%\oem-desktopwallpaper.bmp" copy /y "%~dp0%_mmb%\oem-desktopwallpaper.bmp" "%LOCALAPPDATA%\Microsoft\Wallpaper1.bmp">nul 2>&1
    ping localhost -n 3 >nul
    echo.
    cls
    echo * DONE * == Press Any [KEY] To Return To The Main Menu ==&pause>nul&goto :mainmenu
    ::===========+
    :INFO
    cls &color e
    echo Press any [KEY] To Get Computer Information ...&pause>nul&goto :ci
    :ci
    cls
    :: Get Computer OS
    FOR /F "tokens=2 delims='='" %%A in ('wmic os get Name /value') do SET osname=%%A
    FOR /F "tokens=1 delims='|'" %%A in ("%osname%") do SET osname=%%A
    
    :: Get Computer Serial Number
    FOR /F "tokens=2 delims='='" %%A in ('wmic Bios Get SerialNumber /value') do SET serialnumber=%%A
    
    :: Get Computer Manufacturer
    FOR /F "tokens=2 delims='='" %%A in ('wmic ComputerSystem Get Manufacturer /value') do SET manufacturer=%%A
    
    :: Get Computer Model
    FOR /F "tokens=2 delims='='" %%A in ('wmic ComputerSystem Get Model /value') do SET model=%%A
    
    :: Get Computer Name
    FOR /F "tokens=2 delims='='" %%A in ('wmic OS Get csname /value') do SET system=%%A
    
    :: Get Service Pack
    FOR /F "tokens=2 delims='='" %%A in ('wmic os get ServicePackMajorVersion /value') do SET sp=%%A
    
    echo COMPUTER INFORMATION
    echo ====================
    echo O.S.: %osname%
    echo Serial Number: %serialnumber%
    echo Manufacturer: %manufacturer%
    echo Model: %model%
    echo System Name: %system%
    echo Service Pack: %sp%
    echo ====================
    echo.
    echo * DONE * == Press Any [KEY] To Return To The Main Menu ==&pause>nul&goto :mainmenu
    ::===========+
    :License
    cls &color e
    echo Press any [KEY] To Get License Status ...&pause>nul&goto :ls
    :ls
    cls
    :License Status
    cscript c:\windows\system32\slmgr.vbs -dlv
    echo.
    echo * DONE * == Press Any [KEY] To Return To The Main Menu ==&pause>nul&goto :mainmenu
    ::===========+
    :EOF
    echo.
    set /p =CLOSING MENU In:               <nul
    for /l %%a in (5 -1 1) do (
    set /p =%%a Seconds... <nul&ping -n 2 127.1 >nul
    )
    exit,0
    ::===========+
    
     
  10. ndog

    ndog MDL Novice

    Jul 18, 2009
    22
    8
    0
    Hi Dos Probie thanks for your input!

    I must admit I overlooked backing up .theme files as none of the machines I used it yet have them. I would like to improve the script to include backing up .themes (once I come across such a machine). It also needs to incorporate a routine to properly restore the wallpaper to everyones desktop wallpaper, including the defaultuser profile and it should match the scaling of the OEM type, eg streched etc. Another thing will be to create the backup folder with the proper model, eg Toshiba R850\oem. This can be pulled from wmic as I have learnt from your example.

    As for the existing MDL OEM theme packs these don't suit me as some manufacturers have more than 2 or 3 OEM logos, different wallpapers different sizes etc, some are outdated etc, so I prefer just to quickly do it manually from own backup. That way I know the logo, welcome screen desktop, desktop wallpaper will look like the original and not from a machine from 3 years ago etc..
     
  11. jui

    jui MDL Novice

    Dec 16, 2012
    8
    0
    0
    i'm a noob. how do i run these scripts? i'm trying to save my hp theme and hp welcome logon screens
     
  12. Dos_Probie

    Dos_Probie MDL Senior Member

    Jul 18, 2012
    250
    86
    10
    right-click desktop > New > Text Document > rename to "oem.cmd" then copy and paste script posted on site here.
    That should work for u..
     
  13. jui

    jui MDL Novice

    Dec 16, 2012
    8
    0
    0
    #13 jui, Dec 30, 2012
    Last edited: Dec 30, 2012
    thanks for the reply :)

    edit: actually when saving i selected 'save as' and then 'all files' and named it .bat
    doing that way allowed me to run the script :)