How to Install Multiple Programs in Sequence in Batch Script
When setting up a new computer, you don't just install one app; you install a suite: a browser, an archive tool, a text editor, and a security client. If you try to run all these installers at once, your computer will likely freeze, or you'll get "Another installation in progress" errors. To truly automate a workstation setup, you need a script that is "Patience-Aware": it must start the first installer, wait for it to finish completely, and only then proceed to the next one. A Batch script can use the START /WAIT command to manage this queue, turning a 30-minute manual task into a "Fire and Forget" operation.
This guide will explain how to orchestrate a sequential software deployment.
Method: The "Wait and Verify" Sequence
The start /wait command is the most important tool for sequential automation, combined with exit code checking after each step.
@echo off
set "SourceDir=%~dp0"
set "LogFile=%~dp0deployment.log"
set "FailCount=0"
echo [LOG] Initializing Master Software Deployment...
echo [LOG] DO NOT CLOSE THIS WINDOW.
echo ------------------------------------------
echo Deployment started: %date% %time% > "%LogFile%"
:: 1. Install Chrome (MSI)
if exist "%SourceDir%chrome.msi" (
echo [1/3] Installing Google Chrome...
start /wait "" msiexec /i "%SourceDir%chrome.msi" /qn /norestart
if %errorlevel% equ 0 (
echo [OK] Chrome installed.
echo %date% %time% - Chrome: SUCCESS >> "%LogFile%"
) else if %errorlevel% equ 3010 (
echo [OK] Chrome installed (restart pending^).
echo %date% %time% - Chrome: SUCCESS (3010^) >> "%LogFile%"
) else (
echo [FAIL] Chrome returned exit code: %errorlevel%
echo %date% %time% - Chrome: FAILED (%errorlevel%^) >> "%LogFile%"
set /a FailCount+=1
)
) else (
echo [SKIP] chrome.msi not found.
set /a FailCount+=1
)
:: 2. Install 7-Zip (EXE)
if exist "%SourceDir%7z_setup.exe" (
echo [2/3] Installing 7-Zip...
start /wait "" "%SourceDir%7z_setup.exe" /S
if %errorlevel% equ 0 (
echo [OK] 7-Zip installed.
echo %date% %time% - 7-Zip: SUCCESS >> "%LogFile%"
) else (
echo [FAIL] 7-Zip returned exit code: %errorlevel%
echo %date% %time% - 7-Zip: FAILED (%errorlevel%^) >> "%LogFile%"
set /a FailCount+=1
)
) else (
echo [SKIP] 7z_setup.exe not found.
set /a FailCount+=1
)
:: 3. Install VS Code (User EXE)
if exist "%SourceDir%VSCodeSetup.exe" (
echo [3/3] Installing Visual Studio Code...
start /wait "" "%SourceDir%VSCodeSetup.exe" /verysilent /mergetasks=!runcode
if %errorlevel% equ 0 (
echo [OK] VS Code installed.
echo %date% %time% - VS Code: SUCCESS >> "%LogFile%"
) else (
echo [FAIL] VS Code returned exit code: %errorlevel%
echo %date% %time% - VS Code: FAILED (%errorlevel%^) >> "%LogFile%"
set /a FailCount+=1
)
) else (
echo [SKIP] VSCodeSetup.exe not found.
set /a FailCount+=1
)
echo ------------------------------------------
if %FailCount% equ 0 (
echo [SUCCESS] All 3 programs installed successfully.
) else (
echo [WARNING] %FailCount% program(s^) failed or were skipped.
echo Review the log: %LogFile%
)
pause
Administrative Rights. An automated deployment script needs permission to write to system folders for every app in the list. You MUST run the script as an Administrator.
Method 2: Handling "Reboot Required" Codes
Some installers finish but stay in a "Pending" state until the PC restarts. You can detect this using the %errorlevel% code 3010 and decide how to proceed.
@echo off
set "NeedsReboot=0"
echo [STEP 1] Installing Core Driver...
start /wait "" "%~dp0driver_pkg.exe" /S
if %errorlevel% equ 0 (
echo [OK] Driver installed.
) else if %errorlevel% equ 3010 (
echo [WARNING] Driver installed, but a REBOOT is required.
echo Some features may be unavailable until restart.
set "NeedsReboot=1"
) else (
echo [ERROR] Driver installation failed with exit code: %errorlevel%
pause
exit /b 1
)
echo [STEP 2] Installing application suite...
start /wait "" "%~dp0app_setup.exe" /S
if %errorlevel% equ 0 (
echo [OK] Application installed.
) else (
echo [ERROR] Application installation failed with exit code: %errorlevel%
)
if "%NeedsReboot%"=="1" (
echo.
echo [REMINDER] A system restart is still pending from Step 1.
echo Please restart at your earliest convenience.
)
pause
Method 3: The Dynamic Deployment Loop
Use this to process every installer found in a deployment directory, handling both MSI and EXE formats.
@echo off
set "SourceDir=%~dp0Deploy"
set "LogFile=%~dp0deploy_results.log"
:: Verify the source directory exists
if not exist "%SourceDir%" (
echo [ERROR] Deployment directory not found: %SourceDir%
pause
exit /b 1
)
echo [LOG] Processing all installers in %SourceDir%...
echo Deployment started: %date% %time% > "%LogFile%"
set "Count=0"
:: Process MSI packages
for %%i in ("%SourceDir%\*.msi") do (
echo [ACTION] Deploying: %%~nxi
start /wait "" msiexec /i "%%i" /qn /norestart
if %errorlevel% equ 0 (
echo [OK] %%~nxi
echo %date% %time% - %%~nxi: SUCCESS >> "%LogFile%"
) else (
echo [FAIL] %%~nxi (exit code: %errorlevel%)
echo %date% %time% - %%~nxi: FAILED >> "%LogFile%"
)
set /a Count+=1
)
:: Process EXE installers
for %%i in ("%SourceDir%\*.exe") do (
echo [ACTION] Deploying: %%~nxi
start /wait "" "%%i" /S
if %errorlevel% equ 0 (
echo [OK] %%~nxi
echo %date% %time% - %%~nxi: SUCCESS >> "%LogFile%"
) else (
echo [FAIL] %%~nxi (exit code: %errorlevel%)
echo %date% %time% - %%~nxi: FAILED >> "%LogFile%"
)
set /a Count+=1
)
echo.
echo [DONE] Processed %Count% installer(s). Results logged to: %LogFile%
pause
How to Avoid Common Errors
Wrong Way: Running installers without "START /WAIT"
If you simply list the .exe files in your script, Batch will launch the first one and immediately jump to the second. This leads to a "Collision" where multiple installers try to access the Windows Installer service simultaneously, causing all of them to fail.
Correct Way: Always use start /wait "" "installer.exe" (Method 1). The first pair of quotes "" is the "Title" of the window, always include it to prevent Batch from misinterpreting your installer path as the window title.
Problem: One App Hangs
If one installer turns out not to be "Silent" and shows a pop-up window, your script will stop and wait forever until a human clicks that button.
Solution: Always verify your "Silent Switches" (like /S or /qn) individually before adding a program to your master sequence script.
Best Practices and Rules
1. Identify "Exit Codes"
Check the %errorlevel% after every start /wait line. If an installer returns an error (anything other than 0 or 3010), you might want to stop the script and notify the administrator.
2. Relative Paths (%~dp0)
Store your installers in the same folder as your script and use %~dp0. This ensures that even if you move the folder to a USB drive or a network share, the script can still find the files.
3. Log the Sequence
In an enterprise environment, log every installation result to a file. This allows you to verify that a machine is 100% compliant.
echo %date% %time% - Chrome: SUCCESS on %COMPUTERNAME% >> deployment_history.log
Conclusions
Installing multiple programs in sequence via Batch script is the ultimate "First Step" for professional IT fleet management. By moving from manual clicking to a structured, patient deployment queue, you ensure that every workstation is set up with total consistency and zero collisions. This professional orchestration is essential for maintaining high efficiency during massive hardware refreshes, office moves, or setting up fresh development environments.