I have two PHP versions that I want to execute depending on the situation. I have setup PATH
so that when I type php
there is executed the right version of PHP in the folder C:\xampp\php
.
However, I also have an older version of PHP in the folder C:\old-xampp\php
. Of course, I can't add also that folder path to PATH
as there would be two folders with a file with the name php.exe
and used would be always php.exe
in first folder in PATH
.
At the moment I have to type C:\old-xampp\php\php my-command-here
every time I want to execute my old PHP.
Is there a way to create a .bat file in a PATH
folder with the name old-php.bat
that would act as if I typed C:\old-xampp\php\php
?
I am open to another method to do it too.
CodePudding user response:
There can be written into a batch file old-php.bat
stored in a folder of which path is listed in string value of environment variable Path
the command line:
@C:\old-xampp\php\php.exe %*
%*
references all arguments passed to the batch file exactly as passed to the batch file. This is explained by the usage help of command CALL output on running call /?
in a command prompt window. Argument 0 is the string used to start the batch file which is not included by %*
.
It would be also possible to create in a folder of which path is listed in string value of environment variable Path
a hard link or a symbolic link with a name like old-php.exe
which links to C:\old-xampp\php\php.exe
by using once MKLINK.