@@ -26,6 +26,7 @@ set $defaultInstallPath[1]=C:\wamp64
26
26
set $pathToPhpFolders = bin\php
27
27
28
28
set $cliMode = 0
29
+ set $cliSessionMode = 0
29
30
30
31
set $colorNormal = 08
31
32
set $colorSuccess = 0A
@@ -34,8 +35,23 @@ set $colorFailure=0C
34
35
35
36
36
37
rem --------------------
38
+ rem Operation By CLI
37
39
rem --------------------
38
40
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
+
39
55
rem --------------------
40
56
rem Operation by TUI
41
57
rem --------------------
@@ -166,10 +182,9 @@ rem Operation By CLI
166
182
rem --------------------
167
183
168
184
rem Check if the CLI is being used.
169
- if " %~1 " neq " " (
185
+ if %$cliMode% equ 1 (
170
186
171
- rem Set the CLI mode flag.
172
- set $cliMode = 1
187
+ rem Set the newly selected id.
173
188
set $newSelectionId = 0
174
189
175
190
rem Iterate through the available PHP versions array.
@@ -272,12 +287,21 @@ for /L %%a in (1,1,%$lastUsersEnvironmentalPathArrayId%) do (
272
287
rem Add the selected PHP folder path to the end of the users environmental path string.
273
288
set $usersEnvironmentalPathString = %$usersEnvironmentalPathString%%$pathToPhpFolders% \!$availablePhpVersionsArray[%$newSelectionId%]!
274
289
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
+
279
303
) else (
280
- rem Permanently change the users environmental path string .
304
+ rem Set the user environmental variables .
281
305
setx path " %$usersEnvironmentalPathString% " > nul
282
306
)
283
307
0 commit comments