I need setupcomplete.cmd

Discussion in 'Scripting' started by SpeNRoX, Mar 11, 2016.

  1. SpeNRoX

    SpeNRoX MDL Novice

    Mar 26, 2015
    35
    0
    0
    Hello,

    I need a good script file setupcomplete.cmd or create for Windows 8.1 & Windows 7
     
  2. hearywarlot

    hearywarlot MDL Member

    Jul 31, 2015
    105
    98
    10
    #2 hearywarlot, Mar 12, 2016
    Last edited by a moderator: Apr 20, 2017
    Hello SpeNRoX,

    A good SetupComplete.cmd script is not complex to write.
    It is just a batch script that will execute anything you put into it such as a silent installer, for example: 'install /s /locale=en-us'.
    It should be placed in a folder called '$OEM$\$$\Setup\Scripts' ('$$' translates to 'C:\Windows') under 'sources' in your installation disk.

    But if you want a nice good script to use, here is the one I wrote for Windows 7:
    Code:
    @ECHO OFF
    SETLOCAL ENABLEDELAYEDEXPANSION
    SET "SETUPDIR=%~dp0\RUNONCEEXSETUP"
    SET "INSTDIR=!SETUPDIR!\INST"
    SET "KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx"
    FOR /F "tokens=3 delims= " %%G in ('REG query "HKLM\SYSTEM\ControlSet001\Control\Nls\Language" /V "InstallLanguage"') do (
        IF %%G equ 0413 (
            SET "LDADJ=Extra aanpassingen"
            SET "LDPRM1=Wilt u het installeren van extra aanpassingen Anuleren"
            SET "LDPRM2=Druk op Y voor Anuleren"
            SET "LDPRM3=voor Doorgaan"
            SET "LDINST=Installeren"
            SET "LUNCH= -lang 2067"
            SET "LDTWK=Tweaks toepassen"
            SET "LDREST=Systeem herstarten"
            SET "LDCLN=Opruimen"
        ) ELSE (
            SET "LDADJ=Additional adjustments"
            SET "LDPRM1=Would you like to cancel the extra modifications"
            SET "LDPRM2=Press Y to cancel"
            SET "LDPRM3=to Continue"
            SET "LDINST=Install"
            SET "LDTWK=Apply Tweaks"
            SET "LDREST=Restart system"
            SET "LDCLN=Cleanup"
        )
    )
    
    START /WAIT CMD /C /Q ^& TITLE SetupComplete.cmd ^& FOR /L %%A IN (5,-1,0) do CLS ^& ECHO(!LDPRM1!? ^& ECHO([VC++2005-2015 7zip AkelPad NotepadReplacer Unchecky RegisterTweaks XPGames] ^& ECHO( ^& CHOICE /C YN0 /N /T 1 /D 0 /M "!LDPRM2!, N[%%A] !LDPRM3!." ^& IF not ERRORLEVEL 3 ( EXIT ) else ( IF %%A equ 1 EXIT )
    IF !ERRORLEVEL! equ 2 (
        CALL :RUNONCEEX
    ) ELSE (
        IF !ERRORLEVEL! equ 3 (
            CALL :RUNONCEEX
        ) ELSE (
            REG delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx" /F
        )
    )
    
    REG add "!KEY!" /D "\"!WINDIR!\System32\rundll32.exe\" \"!WINDIR!\System32\iernonce.dll,RunOnceExProcess\"" /F
    REG add "!KEY!" /V "TITLE" /D "!LDADJ!" /F
    REG add "!KEY!" /V "Flags" /T REG_DWORD /D "20" /F
    
    REG add "!KEY!\1000" /VE /D "!LDCLN!" /F
    REG add "!KEY!\1000" /V "1" /D "\"!SETUPDIR!\Cleanup.cmd\"" /F
    
    EXIT /B
    
    
    :RUNONCEEX
    
    REG add "!KEY!\0001" /VE /D "!LDINST! 7-zip 15.14" /F
    REG add "!KEY!\0001" /V "1" /D "\"!INSTDIR!\7z1514-x64.exe\" /S" /F
    
    REG add "!KEY!\0010" /VE /D "!LDINST! AkelPad 4.9.7" /F
    REG add "!KEY!\0010" /V "1" /D "\"!INSTDIR!\AkelPad-4.9.7-x64-setup.exe\" /S /SHORTCUT=0x4" /F
    
    REG add "!KEY!\0011" /VE /D "!LDINST! NotepadReplacer 1.1.6" /F
    REG add "!KEY!\0011" /V "1" /D "\"!INSTDIR!\NotepadReplacerSetup-1.1.6.exe\" /SILENT /NOTEPAD=\"!PROGRAMFILES!\AkelPad\AkelPad.exe\"" /F
    
    REG add "!KEY!\0100" /VE /D "!LDINST! Unchecky 0.4.2" /F
    REG add "!KEY!\0100" /V "1" /D "\"!INSTDIR!\unchecky_setup.exe\" -install -path \"!PROGRAMFILES!\Unchecky\"!LUNCH! -no_desktop_icon" /F
    
    REG add "!KEY!\0101" /VE /D "!LDINST! Win XP Pinball and Sudoku" /F
    REG add "!KEY!\0101" /V "1" /D "\"!INSTDIR!\MicrosoftXPSudPin.exe\" /S" /F
    
    REG add "!KEY!\0110" /VE /D "!LDINST! Microsoft Visual C++ 2005/2008/2010/2012/2013/2015/Legacy runtimes" /F
    REG add "!KEY!\0110" /V "1" /D "\"!INSTDIR!\VBCRedist_AIO_x86_x64.exe\" /y" /F
    
    REG add "!KEY!\0111" /VE /D "!LDTWK!" /F
    REG add "!KEY!\0111" /V "1" /D "\"!SETUPDIR!\Tweaks.cmd\"" /F
    
    REG add "!KEY!\1001" /VE /D "!LDREST!" /F
    REG add "!KEY!\1001" /V "1" /D "\"!WINDIR!\System32\shutdown.exe\" /R /T 3" /F
    
    GOTO :EOF
    Here is the one I wrote for 8.1 and 10 (basically the same, but will autoactivate Windows if MSDM table exists in BIOS with valid embedded product key):
    Code:
    @ECHO OFF
    SETLOCAL ENABLEDELAYEDEXPANSION
    SET "SETUPDIR=%~dp0\RUNONCEEXSETUP"
    SET "INSTDIR=!SETUPDIR!\INST"
    SET "KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx"
    FOR /F "tokens=3 delims= " %%G in ('REG query "HKLM\SYSTEM\ControlSet001\Control\Nls\Language" /V "InstallLanguage"') do (
        IF %%G equ 0413 (
            SET "LDADJ=Extra aanpassingen"
            SET "LDPRM1=Wilt u het installeren van extra aanpassingen Anuleren"
            SET "LDPRM2=Druk op Y voor Anuleren"
            SET "LDPRM3=voor Doorgaan"
            SET "LDINST=Installeren"
            SET "LUNCH= -lang 2067"
            SET "LDTWK=Tweaks toepassen"
            SET "LDCLN=Opruimen"
        ) ELSE (
            SET "LDADJ=Additional adjustments"
            SET "LDPRM1=Would you like to cancel the extra modifications"
            SET "LDPRM2=Press Y to cancel"
            SET "LDPRM3=to Continue"
            SET "LDINST=Install"
            SET "LDTWK=Apply Tweaks"
            SET "LDCLN=Cleanup"
        )
    )
    
    START /WAIT CMD /C /Q ^& TITLE SetupComplete.cmd ^& FOR /L %%A IN (5,-1,0) do CLS ^& ECHO(!LDPRM1!? ^& ECHO([VC++2005-2015 7zip AkelPad NotepadReplacer Unchecky RegisterTweaks Win7XPGames] ^& ECHO( ^& CHOICE /C YN0 /N /T 1 /D 0 /M "!LDPRM2!, N[%%A] !LDPRM3!." ^& IF not ERRORLEVEL 3 ( EXIT ) else ( IF %%A equ 1 EXIT )
    IF !ERRORLEVEL! equ 2 (
        CALL :RUNONCEEX
    ) ELSE (
        IF !ERRORLEVEL! equ 3 (
            CALL :RUNONCEEX
        ) ELSE (    
            REG delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx" /F
        )
    )
    
    REG add "!KEY!" /D "\"!WINDIR!\System32\rundll32.exe\" \"!WINDIR!\System32\iernonce.dll,RunOnceExProcess\"" /F
    REG add "!KEY!" /V "TITLE" /D "!LDADJ!" /F
    REG add "!KEY!" /V "Flags" /T REG_DWORD /D "20" /F
    
    REG add "!KEY!\1000" /VE /D "!LDCLN!" /F
    REG add "!KEY!\1000" /V "1" /D "\"!SETUPDIR!\Cleanup.cmd\"" /F
    
    CD /D "%~dp0"
    "get_win8key.exe" >nul 2>&1
    IF !ERRORLEVEL! equ 0 (
        FOR /F %%A in ('get_win8key.exe') do (
            CSCRIPT /nologo "!WINDIR!\system32\slmgr.vbs" /ipk %%A
            CSCRIPT /nologo "!WINDIR!\system32\slmgr.vbs" /ato
        )
    )
    
    EXIT /B
    
    
    :RUNONCEEX
    
    REG add "!KEY!\0001" /VE /D "!LDINST! 7-zip 15.14" /F
    REG add "!KEY!\0001" /V "1" /D "\"!INSTDIR!\7z1514-x64.exe\" /S" /F
    
    REG add "!KEY!\0010" /VE /D "!LDINST! AkelPad 4.9.7" /F
    REG add "!KEY!\0010" /V "1" /D "\"!INSTDIR!\AkelPad-4.9.7-x64-setup.exe\" /S /SHORTCUT=0x4" /F
    
    REG add "!KEY!\0011" /VE /D "!LDINST! NotepadReplacer 1.1.6" /F
    REG add "!KEY!\0011" /V "1" /D "\"!INSTDIR!\NotepadReplacerSetup-1.1.6.exe\" /SILENT /NOTEPAD=\"!PROGRAMFILES!\AkelPad\AkelPad.exe\"" /F
    
    REG add "!KEY!\0100" /VE /D "!LDINST! Unchecky 0.4.2" /F
    REG add "!KEY!\0100" /V "1" /D "\"!INSTDIR!\unchecky_setup.exe\" -install -path \"!PROGRAMFILES!\Unchecky\"!LUNCH! -no_desktop_icon" /F
    
    REG add "!KEY!\0101" /VE /D "!LDINST! Win 7 and XP Microsoft Games" /F
    REG add "!KEY!\0101" /V "1" /D "\"!INSTDIR!\Win7GamesForWin10-Setup.exe\" /S" /F
    REG add "!KEY!\0101" /V "2" /D "\"!INSTDIR!\MicrosoftXPSudPin.exe\" /S" /F
    
    REG add "!KEY!\0110" /VE /D "!LDINST! Microsoft Visual C++ 2005/2008/2010/2012/2013/2015/Legacy runtimes" /F
    REG add "!KEY!\0110" /V "1" /D "\"!INSTDIR!\VBCRedist_AIO_x86_x64.exe\" /y" /F
    
    REG add "!KEY!\0111" /VE /D "!LDTWK!" /F
    REG add "!KEY!\0111" /V "1" /D "\"!SETUPDIR!\Tweaks.cmd\"" /F
    
    GOTO :EOF
    First it sets global vars for root setup folder, installation software folders (%~dp0 = Current working Dir) and RunOnceEx register path.
    These scripts will first check your systems locale to see if it is Dutch (can be extended for more locales), else it chooses English.
    Based on the locale, it will change the language of the script and command parameters so it fits better for the user.

    Then it will open a prompt for 5 seconds which allow you to cancel (Y) or continue (N) modifications.
    If you let it continue, it will add registry keys to enable runonceex which will open a dialog on first login and add additional entries which will execute the programs and scripts of your choice.

    After adding registry keys it will execute a program called 'get_win8key' which will do one thing, which is output contents of MSDN table (embedded product key).
    The script will parse the output in a for loop and send the key to 'slmgr.vbs', the CLI activation program of Windows.


    I recommend naming your script 'oobe.cmd' so it will execute in OOBE, thus before product key verification part so the script will activate Windows if key exists in BIOS and skip product key verification.
    This is handy since you can now add ei.cfg and choose all 8.1 or 10 versions and not have to deal with auto activation since the script will fix this.


    Well that was a mouthfull, hopefully this has helped you ^_^.
    If you want I can also send you a link with the contents of my $OEM$ folder I add to my ISO's.

    Have a nice day.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...