In order to be able to execute insde a console, you only have to create the which.bat file with the contents I included here and put it on the PHP interpreter's folder. Of course, you will need to add that folder to the PATH enviorement variable.
which.bat
@"%~dp0\php.exe" -r"$cmd_to_check = $argv[1]; $exts = array('exe', 'bat', 'cmd'); foreach (explode(';', getenv('PATH')) as $path) { foreach ($exts as $ext) { $file = $path . '\\' . $cmd_to_check . '.' . $ext; if (is_file($file)) { echo $file; exit; } } } echo $test . ' not found';" %*
Expanded code:
<?php $cmd_to_check = $argv[1]; $exts = array('exe', 'bat', 'cmd'); foreach (explode(';', getenv('PATH')) as $path) { foreach ($exts as $ext) { $file = $path . '\\' . $cmd_to_check . '.' . $ext; if (is_file($file)) { echo $file; exit; } } }
Usage:
C:\>which php c:\php\php.exe
No comments:
Post a Comment