Skip to content

Commit 2d53fb5

Browse files
authored
Refactor DeployWorkstation.bat for clarity and updates
1 parent 7137666 commit 2d53fb5

1 file changed

Lines changed: 17 additions & 20 deletions

File tree

DeployWorkstation.bat

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@echo off
2+
title DeployWorkstation Launcher v5.1
23
REM ========================================================
3-
REM DeployWorkstation.bat
4-
REM Launcher for DeployWorkstation.ps1
4+
REM DeployWorkstation.bat - Launcher for DeployWorkstation.ps1
55
REM Version 5.1 - PNWC Edition
66
REM ========================================================
77

@@ -12,37 +12,40 @@ echo ===== DeployWorkstation Launcher v5.1 =====
1212
echo.
1313

1414
REM --------------------------------------------------------
15-
REM 1) Elevation check - re-launch elevated if not admin
15+
REM Elevation check - re-launch elevated if not admin
1616
REM --------------------------------------------------------
1717
net session >nul 2>&1
1818
if %errorlevel% neq 0 (
1919
echo Requesting administrative privileges...
20-
echo Please click "Yes" in the UAC prompt.
20+
echo Please accept the UAC prompt.
2121
echo.
22-
powershell.exe -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs -Wait"
23-
exit /b
22+
powershell.exe -NoProfile -Command "Start-Process cmd.exe -ArgumentList '/c "%~f0"' -Verb RunAs"
23+
exit /b 0
2424
)
2525

2626
echo [OK] Running as Administrator.
2727
echo.
2828

2929
REM --------------------------------------------------------
30-
REM 2) Change to the directory containing this .bat
30+
REM Change to the directory containing this .bat
3131
REM --------------------------------------------------------
3232
pushd "%~dp0"
3333

3434
REM --------------------------------------------------------
35-
REM 3) Verify the PowerShell script is present
35+
REM Verify the PowerShell script is present
3636
REM --------------------------------------------------------
3737
if not exist "DeployWorkstation.ps1" (
38-
echo [ERROR] DeployWorkstation.ps1 not found.
39-
echo Expected: %~dp0DeployWorkstation.ps1
38+
echo [ERROR] DeployWorkstation.ps1 not found in:
39+
echo %~dp0
4040
echo.
41+
echo Both files must be in the same folder.
42+
echo.
43+
pause
4144
goto :error_exit
4245
)
4346

4447
REM --------------------------------------------------------
45-
REM 4) Menu
48+
REM Menu
4649
REM --------------------------------------------------------
4750
:menu
4851
echo Select deployment mode:
@@ -83,7 +86,7 @@ if "%choice%"=="1" (
8386
)
8487

8588
REM --------------------------------------------------------
86-
REM 5) Show parameters then launch
89+
REM Launch
8790
REM --------------------------------------------------------
8891
if "!ps_params!"=="" (
8992
echo Parameters : (none - full run)
@@ -100,32 +103,26 @@ if "!ps_params!"=="" (
100103
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "DeployWorkstation.ps1" !ps_params!
101104
)
102105

103-
REM Capture exit code immediately before anything can overwrite it
104106
set "ps_exit=%errorlevel%"
105107

106-
REM --------------------------------------------------------
107-
REM 6) Result
108-
REM --------------------------------------------------------
109108
echo.
110109
if "%ps_exit%"=="0" (
111110
echo ===== Deployment completed successfully =====
112111
) else (
113112
echo ===== Deployment finished with errors =====
114-
echo Exit code : %ps_exit%
115-
echo Check DeployWorkstation.log in this folder for details.
113+
echo Exit code : %ps_exit%
114+
echo Log file : %~dp0DeployWorkstation.log
116115
)
117116

118117
goto :normal_exit
119118

120-
REM --------------------------------------------------------
121119
:error_exit
122120
echo.
123121
echo ===== Launch aborted =====
124122
popd
125123
pause
126124
exit /b 1
127125

128-
REM --------------------------------------------------------
129126
:normal_exit
130127
popd
131128
echo.

0 commit comments

Comments
 (0)