Application Packaging - Batch Script
Scenarios (Q&A)
1. How would you silently install an MSI with a transform (MST) file and
create a log?
Scenario: You're packaging "AcmeApp" which requires a custom
MST and a log for installation tracking.
Answer:
msiexec /i "AcmeApp.msi" TRANSFORMS="AcmeApp.mst" /qn /log "C:\Logs\
AcmeApp_Install.log"
2. How can you prevent installation if the app is already installed (using
registry check)?
Scenario: You want to avoid reinstalling "SecureClient" if it's already
present.
Answer:
reg query "HKLM\Software\SecureClient" >nul 2>&1
if %ERRORLEVEL%==0 (
echo Application already installed.
exit /B 0
)
msiexec /i "SecureClient.msi" /qn
3. How do you kill a running process before starting installation?
Scenario: "AppViewer.exe" must be closed before upgrade.
Answer:
taskkill /IM "AppViewer.exe" /F
timeout /T 5
msiexec /i "AppViewer_Upgrade.msi" /qn
4. How would you copy installation files and ensure the target folder
exists?
Scenario: Your application requires placing config files in a specific
folder.
Answer:
if not exist "C:\Program Files\App\Config" (
mkdir "C:\Program Files\App\Config"
)
xcopy /E /I /Y ".\Configs" "C:\Program Files\App\Config"
5. How do you uninstall an MSI package silently?
Scenario: You need to remove "OldTool" from all machines.
Answer:
msiexec /x "{GUID-FOR-OldTool}" /qn /log "C:\Logs\OldTool_Uninstall.log"
6. How do you log the system information before installation?
Scenario: Your deployment team wants machine info logged before
installing "AgentX".
Answer:
systeminfo > "C:\Logs\AgentX_SystemInfo.txt"
msiexec /i "AgentX.msi" /qn
7. How do you add a registry value post-installation?
Scenario: You need to flag that "FinanceApp" is installed via registry.
Answer:
reg add "HKLM\Software\FinanceApp" /v "InstalledByIT" /t REG_SZ /d "Yes" /f
8. How do you set a system-wide environment variable?
Scenario: "DevKit" requires a DEV_HOME variable after install.
Answer:
setx DEV_HOME "C:\Program Files\DevKit" /M
9. How do you remove old logs and leftover folders before installing a
new version?
Scenario: You're deploying "LoggerApp v2" and want to clean old
logs.
Answer:
del /Q /F "C:\Logs\LoggerApp\*.*"
rd /S /Q "C:\Program Files\LoggerApp"
msiexec /i "LoggerApp_v2.msi" /qn
10. How do you create a desktop shortcut after installation using a pre-
created .lnk file?
Scenario: "BrowserPlus" doesn’t create shortcuts by default.
Answer:
copy /Y "C:\Program Files\BrowserPlus\BrowserPlus.lnk" "C:\Users\Public\Desktop\
BrowserPlus.lnk"