@@ -26,6 +26,7 @@ set $defaultInstallPath[1]=C:\wamp64
2626set $pathToPhpFolders = bin\php
2727
2828set $cliMode = 0
29+ set $cliSessionMode = 0
2930
3031set $colorNormal = 08
3132set $colorSuccess = 0A
@@ -34,8 +35,23 @@ set $colorFailure=0C
3435
3536
3637rem --------------------
38+ rem Operation By CLI
3739rem --------------------
3840
41+ rem Check if the CLI is being used.
42+ if " %1 " neq " " (
43+ set $cliMode = 1
44+
45+ rem Check if the CLI session mode is being used.
46+ if " %2 " == " -t" (
47+ set $cliSessionMode = 1
48+ )
49+
50+ if " %2 " == " --temp" (
51+ set $cliSessionMode = 1
52+ )
53+ )
54+
3955rem --------------------
4056rem Operation by TUI
4157rem --------------------
@@ -166,10 +182,9 @@ rem Operation By CLI
166182rem --------------------
167183
168184rem Check if the CLI is being used.
169- if " %~1 " neq " " (
185+ if %$cliMode% equ 1 (
170186
171- rem Set the CLI mode flag.
172- set $cliMode = 1
187+ rem Set the newly selected id.
173188 set $newSelectionId = 0
174189
175190 rem Iterate through the available PHP versions array.
@@ -272,12 +287,21 @@ for /L %%a in (1,1,%$lastUsersEnvironmentalPathArrayId%) do (
272287rem Add the selected PHP folder path to the end of the users environmental path string.
273288set $usersEnvironmentalPathString = %$usersEnvironmentalPathString%%$pathToPhpFolders% \!$availablePhpVersionsArray[%$newSelectionId%]!
274289
275- rem Check if the change is for an open session only.
276- if " %~2 " eq " --temp" (
277- rem Temporary change the users environmental path string in the open session only.
278- set path " %$usersEnvironmentalPathString% " > nul
290+ rem Check if the CLI session mode is being used.
291+ if %$cliSessionMode% equ 1 (
292+ rem Set 'session' path (which is a combination of both system and user environmental variables).
293+
294+ rem 1: %path% contains both system and user environmental variables.
295+ rem 2: Get %path% string, remove 'permanent' php path and add 'temporary' php path.
296+
297+ echo Success: The session PHP CLI version is now !$availablePhpVersionsArray[%$newSelectionId%]!
298+
299+ endlocal && set " Path = %$usersEnvironmentalPathString% " > nul
300+
301+ exit /B 0
302+
279303) else (
280- rem Permanently change the users environmental path string .
304+ rem Set the user environmental variables .
281305 setx path " %$usersEnvironmentalPathString% " > nul
282306)
283307
0 commit comments