11@ echo off
22REM ========================================================
3- REM DeployWorkstation-Launcher .bat
4- REM Ensures elevation, then runs DeployWorkstation.ps1
5- REM Compatible with the optimized PowerShell script
3+ REM DeployWorkstation.bat
4+ REM Launcher for DeployWorkstation.ps1
5+ REM Version 5.1 – PNWC Edition
66REM ========================================================
77
88setlocal enabledelayedexpansion
99
1010echo .
11- echo ===== DeployWorkstation Launcher =====
11+ echo ===== DeployWorkstation Launcher v5.1 =====
1212echo .
1313
14- REM 1) Check if we're already elevated
14+ REM --------------------------------------------------------
15+ REM 1) Elevation check
16+ REM Re-launch this .bat elevated if not already admin.
17+ REM --------------------------------------------------------
1518net session > nul 2 >& 1
1619if %errorlevel% neq 0 (
1720 echo Requesting administrative privileges...
18- echo Please click " Yes" in the UAC prompt that appears .
21+ echo Please click " Yes" in the UAC prompt.
1922 echo .
20-
21- REM Re-launch this batch file with elevation
2223 powershell.exe -NoProfile -Command ^
23- " Start-Process -FilePath '%~f0 ' -Verb RunAs -Wait"
24-
25- REM Exit the non-elevated instance
24+ " Start-Process -FilePath '%~f0 ' -Verb RunAs -Wait"
2625 exit /b
2726)
2827
29- REM 2) We're now elevated - show confirmation
30- echo Administrative privileges confirmed.
31- echo Current directory: %~dp0
28+ echo [OK] Running as Administrator.
3229echo .
3330
34- REM 3) Change to script directory
31+ REM --------------------------------------------------------
32+ REM 2) Change to the directory containing this .bat
33+ REM --------------------------------------------------------
3534pushd " %~dp0 "
3635
37- REM 4) Check if PowerShell script exists
36+ REM --------------------------------------------------------
37+ REM 3) Verify the PowerShell script is present
38+ REM --------------------------------------------------------
3839if not exist " DeployWorkstation.ps1" (
39- echo ERROR: DeployWorkstation.ps1 not found in current directory!
40- echo Expected location : %~dp0 DeployWorkstation.ps1
40+ echo [ ERROR] DeployWorkstation.ps1 not found.
41+ echo Expected : %~dp0 DeployWorkstation.ps1
4142 echo .
4243 goto :error_exit
4344)
4445
45- REM 5) Show options menu
46- echo Available options:
47- echo 1. Full deployment (remove bloatware + install apps)
46+ REM --------------------------------------------------------
47+ REM 4) Menu
48+ REM --------------------------------------------------------
49+ :menu
50+ echo Select deployment mode:
51+ echo .
52+ echo 1. Full deployment (remove bloatware + install apps + configure system)
4853echo 2. Remove bloatware only
4954echo 3. Install apps only
50- echo 4. Exit
55+ echo 4. System configuration only
56+ echo 5. Exit
5157echo .
52- set /p choice = " Enter your choice (1-4): "
58+ set " choice = "
59+ set /p choice = " Enter choice (1-5): "
5360
54- REM 6) Set PowerShell parameters based on choice
5561set " ps_params = "
62+
5663if " %choice% " == " 1" (
57- echo Running full deployment.. .
58- set " ps_params = "
64+ echo .
65+ echo [*] Full deployment selected.
5966) else if " %choice% " == " 2" (
60- echo Running bloatware removal only...
61- set " ps_params = -SkipAppInstall"
67+ echo .
68+ echo [*] Bloatware removal only.
69+ set " ps_params = -SkipAppInstall -SkipSystemConfig"
6270) else if " %choice% " == " 3" (
63- echo Running app installation only...
64- set " ps_params = -SkipBloatwareRemoval"
71+ echo .
72+ echo [*] App installation only.
73+ set " ps_params = -SkipBloatwareRemoval -SkipSystemConfig"
6574) else if " %choice% " == " 4" (
66- echo Exiting...
75+ echo .
76+ echo [*] System configuration only.
77+ set " ps_params = -SkipBloatwareRemoval -SkipAppInstall"
78+ ) else if " %choice% " == " 5" (
79+ echo Exiting.
6780 goto :normal_exit
6881) else (
69- echo Invalid choice. Running full deployment...
70- set " ps_params = "
82+ echo [!] Invalid choice - please try again.
83+ echo .
84+ goto :menu
7185)
7286
87+ REM --------------------------------------------------------
88+ REM 5) Show what will run, then launch
89+ REM --------------------------------------------------------
90+ if " !ps_params! " == " " (
91+ echo Parameters : (none - full run)
92+ ) else (
93+ echo Parameters : !ps_params!
94+ )
7395echo .
74- echo Starting PowerShell script with Windows PowerShell 5.1...
75- echo Parameters: %ps_params%
96+ echo Starting Windows PowerShell 5.1...
7697echo .
7798
78- REM 7) Run the PowerShell script with proper parameters
79- if " %ps_params% " == " " (
99+ if " !ps_params! " == " " (
80100 powershell.exe -NoProfile -ExecutionPolicy Bypass -File " DeployWorkstation.ps1"
81101) else (
82- powershell.exe -NoProfile -ExecutionPolicy Bypass -File " DeployWorkstation.ps1" % ps_params%
102+ powershell.exe -NoProfile -ExecutionPolicy Bypass -File " DeployWorkstation.ps1" ! ps_params!
83103)
84104
85- REM 8) Check exit code and report results
86- if %errorlevel% equ 0 (
87- echo .
105+ REM Capture exit code immediately before anything can overwrite it
106+ set " ps_exit = %errorlevel% "
107+
108+ REM --------------------------------------------------------
109+ REM 6) Result
110+ REM --------------------------------------------------------
111+ echo .
112+ if " %ps_exit% " == " 0" (
88113 echo ===== Deployment completed successfully =====
89114) else (
90- echo .
91- echo ===== Deployment completed with errors =====
92- echo Exit code: %errorlevel%
93- echo Check the log file for details.
115+ echo ===== Deployment finished with errors =====
116+ echo Exit code : %ps_exit%
117+ echo Check DeployWorkstation.log in this folder for details.
94118)
95119
96120goto :normal_exit
97121
122+ REM --------------------------------------------------------
98123:error_exit
99124echo .
100- echo ===== Deployment failed =====
125+ echo ===== Launch aborted =====
101126popd
102127pause
103128exit /b 1
104129
130+ REM --------------------------------------------------------
105131:normal_exit
106- REM 9) Return to original directory and pause
107132popd
108133echo .
109- echo Press any key to exit ...
134+ echo Press any key to close ...
110135pause > nul
111- exit /b 0
136+ exit /b 0
0 commit comments