Windows 7 - Launch Bat after installation (SetupComplete?)

Discussion in 'Windows 7' started by ieuagn321980hr, Feb 6, 2014.

  1. ieuagn321980hr

    ieuagn321980hr MDL Novice

    Dec 5, 2013
    8
    0
    0
    #1 ieuagn321980hr, Feb 6, 2014
    Last edited: Feb 6, 2014
    Hello guys!
    I'm wondering about a script I made after the installation of my Windows 7 x64 ISO is done. The script (bat) contains this:


    @echo off
    cd C:\Users\
    RD /S /Q "C:\Users\Public\"

    cd C:\Users\Unknown\
    ATTRIB +H "C:\Users\Unknown\Desktop"
    RD /S /Q "C:\Users\Unknown\Searches"
    RD /S /Q "C:\Users\Unknown\Saved Games"
    RD /S /Q "C:\Users\Unknown\Videos"
    RD /S /Q "C:\Users\Unknown\Links"
    RD /S /Q "C:\Users\Unknown\Favorites"
    RD /S /Q "C:\Users\Unknown\Contacts"

    cd C:\
    RD /S /Q "C:\PerfLogs\"
    RD /S /Q "C:\Program Files\Uninstall Information"
    RD /S /Q "C:\Program Files\Windows Media Player"
    ATTRIB +H "C:\Program Files\Common Files" /S /D
    ATTRIB +H "C:\Program Files\DVD Maker" /S /D
    ATTRIB +H "C:\Program Files\Internet Explorer" /S /D
    ATTRIB +H "C:\Program Files\MSBuild" /S /D
    ATTRIB +H "C:\Program Files\Reference Assemblies" /S /D
    ATTRIB +H "C:\Program Files\Windows Defender" /S /D
    ATTRIB +H "C:\Program Files\Windows Mail" /S /D
    ATTRIB +H "C:\Program Files\Windows NT" /S /D
    ATTRIB +H "C:\Program Files\Windows Photo Viewer" /S /D

    cd C:\Program Files (x86)\
    RD /S /Q "C:\Program Files (x86)\Uninstall Information"
    ATTRIB +H "C:\Program Files (x86)\Common Files" /S /D
    ATTRIB +H "C:\Program Files (x86)\Internet Explorer" /S /D
    ATTRIB +H "C:\Program Files (x86)\MSBuild" /S /D
    ATTRIB +H "C:\Program Files (x86)\Reference Assemblies" /S /D
    ATTRIB +H "C:\Program Files (x86)\Windows Defender" /S /D
    ATTRIB +H "C:\Program Files (x86)\Windows Mail" /S /D
    ATTRIB +H "C:\Program Files (x86)\Windows NT" /S /D
    ATTRIB +H "C:\Program Files (x86)\Windows Photo Viewer" /S /D




    cd C:\ProgramData\Microsoft\Windows\Start Menu\
    RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"
    RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Maintenance"
    RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Games"
    RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell"
    RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\System Tools"
    RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Accessibility"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Default Programs.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Windows Update.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Sync Center.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Sound Recorder.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Remote Desktop Connection.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Paint.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\displayswitch.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Calculator.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Welcome Center.lnk"

    cd C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\
    RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\"
    RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Maintenance\"
    RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools\"
    RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Accessibility"
    RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\System Tools"
    DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Windows Explorer.lnk"
    DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Run.lnk"
    DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Command Prompt.lnk"

    C:\Windows\
    RD /S /Q "C:\Windows\Downloaded Program Files"
    RD /S /Q "C:\Windows\LiveKernelReports"
    RD /S /Q "C:\Windows\Logs"
    RD /S /Q "C:\Windows\ModemLogs"
    RD /S /Q "C:\Windows\Offline Web Pages"
    RD /S /Q "C:\Windows\Temp"
    RD /S /Q "C:\Windows\WinToolkit"





    cd C:\ProgramData\Microsoft\User Account Pictures\
    REN "C:\ProgramData\Microsoft\User Account Pictures\user.bmp" "user.x"
    REN "C:\ProgramData\Microsoft\User Account Pictures\guest.bmp" "guest.x"




    How should I implant this script after the Win7 installation is done. Tried with SetupComplete (see spolier):


    \sources\$OEM$\$$\Setup\Scripts


    @ECHO OFF
    %~dp0"Windows Loader.exe" /silent /preactivate
    cd %~dp0
    attrib -R -A -S -H *.*
    SHUTDOWN /R /T 5
    RMDIR /S /Q "%WINDIR%\Setup\Scripts"

    @echo off
    cd C:\Users\
    RD /S /Q "C:\Users\Public\"

    cd C:\Users\Unknown\
    ATTRIB +H "C:\Users\Unknown\Desktop"
    RD /S /Q "C:\Users\Unknown\Searches"
    RD /S /Q "C:\Users\Unknown\Saved Games"
    RD /S /Q "C:\Users\Unknown\Videos"
    RD /S /Q "C:\Users\Unknown\Links"
    RD /S /Q "C:\Users\Unknown\Favorites"
    RD /S /Q "C:\Users\Unknown\Contacts"

    cd C:\
    RD /S /Q "C:\PerfLogs\"
    RD /S /Q "C:\Program Files\Uninstall Information"
    RD /S /Q "C:\Program Files\Windows Media Player"
    ATTRIB +H "C:\Program Files\Common Files" /S /D
    ATTRIB +H "C:\Program Files\DVD Maker" /S /D
    ATTRIB +H "C:\Program Files\Internet Explorer" /S /D
    ATTRIB +H "C:\Program Files\MSBuild" /S /D
    ATTRIB +H "C:\Program Files\Reference Assemblies" /S /D
    ATTRIB +H "C:\Program Files\Windows Defender" /S /D
    ATTRIB +H "C:\Program Files\Windows Mail" /S /D
    ATTRIB +H "C:\Program Files\Windows NT" /S /D
    ATTRIB +H "C:\Program Files\Windows Photo Viewer" /S /D

    cd C:\Program Files (x86)\
    RD /S /Q "C:\Program Files (x86)\Uninstall Information"
    ATTRIB +H "C:\Program Files (x86)\Common Files" /S /D
    ATTRIB +H "C:\Program Files (x86)\Internet Explorer" /S /D
    ATTRIB +H "C:\Program Files (x86)\MSBuild" /S /D
    ATTRIB +H "C:\Program Files (x86)\Reference Assemblies" /S /D
    ATTRIB +H "C:\Program Files (x86)\Windows Defender" /S /D
    ATTRIB +H "C:\Program Files (x86)\Windows Mail" /S /D
    ATTRIB +H "C:\Program Files (x86)\Windows NT" /S /D
    ATTRIB +H "C:\Program Files (x86)\Windows Photo Viewer" /S /D




    cd C:\ProgramData\Microsoft\Windows\Start Menu\
    RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"
    RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Maintenance"
    RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Games"
    RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell"
    RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\System Tools"
    RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Accessibility"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Default Programs.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Windows Update.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Sync Center.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Sound Recorder.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Remote Desktop Connection.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Paint.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\displayswitch.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Calculator.lnk"
    DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Welcome Center.lnk"

    cd C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\
    RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\"
    RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Maintenance\"
    RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools\"
    RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Accessibility"
    RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\System Tools"
    DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Windows Explorer.lnk"
    DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Run.lnk"
    DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Command Prompt.lnk"

    C:\Windows\
    RD /S /Q "C:\Windows\Downloaded Program Files"
    RD /S /Q "C:\Windows\LiveKernelReports"
    RD /S /Q "C:\Windows\Logs"
    RD /S /Q "C:\Windows\ModemLogs"
    RD /S /Q "C:\Windows\Offline Web Pages"
    RD /S /Q "C:\Windows\Temp"
    RD /S /Q "C:\Windows\WinToolkit"


    cd C:\ProgramData\Microsoft\User Account Pictures\
    REN "C:\ProgramData\Microsoft\User Account Pictures\user.bmp" "user.x"
    REN "C:\ProgramData\Microsoft\User Account Pictures\guest.bmp" "guest.x"



    Problem is, I cant use GPO either because I do prefer Home Premium. Many thanks guys and love yaaaa <3
     
  2. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,458
    981
    60
    put into your setupcomplete.cmd file ($oem$ folder) this as a bat file. Name it "auto.bat" and put that in there. it would run.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Psych0-Smil3s

    Psych0-Smil3s MDL Novice

    Feb 14, 2014
    5
    0
    0
    I am very interested in this process, there have been several things i wanted to automate AFTER completion along with auto unattend but what exactly does this particular script do?
     
  4. s1ave77

    s1ave77 MDL Guide Dog/Dev

    Aug 15, 2012
    14,973
    19,916
    340
    #4 s1ave77, Feb 15, 2014
    Last edited by a moderator: Apr 20, 2017
    As i need user-folders already created i use setupcomplete.cmd to assign an install script to be executed on next reboot. This will install programs, set reg keys and copy settings-files to appropriate user-folders before Windows boots for the first run.


    looks that way:
    Code:
    @echo off
    
    setlocal ENABLEDELAYEDEXPANSION
    
    pushd "%~dp0"
    cd %~dp0
    
    ::===============================================================================================================
    
    Reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx" /v Title /t REG_SZ /d BootTask /f
    Reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx" /v Flags /t REG_DWORD /d 2 /f
    Reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0001" /v MyScript /t REG_SZ /d "C:\Windows\Setup\Scripts\files\boottask.cmd" /f
    
    :Exit
    ENDLOCAL
    exit
    
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Kamrul08

    Kamrul08 MDL Member

    Dec 28, 2013
    101
    12
    10
    I think you should keep the the commands "SHUTDOWN /R /T 5" at the end of your command file. So your full command will work fine.