.bat
每当我单击按钮或超链接时,我都需要在命令提示符下运行文件。我写的代码是:
<?php
if(isset($_POST['submit']))
{
$param_val = 1;
$test='main.bat $par';
// exec('c:\WINDOWS\system32\cmd.exe /c START C:/wamp/www/demo/m.bat');
// exec('cmd /c C:/wamp/www/demo/m.bat');
// exec('C:/WINDOWS/system32/cmd.exe');
// exec('cmd.exe /c C:/wamp/www/demo/main.bat');
exec('$test');
}
else
{
?>
<form action="" method="post">
<input type="submit" name="submit" value="Run">
</form>
<?php
}
?>
我main.bat
的是:
@echo off
cls
:start
echo.
echo 1.append date and time into log file
echo 2.just ping google.com
set/p choice="select your option?"
if '%choice%'=='1' goto :choice1
if '%choice%'=='2' goto :choice2
echo "%choice%" is not a valid option. Please try again.
echo.
goto start
:choice1
call append.bat
goto end
:choice2
call try.bat
goto end
:end
pause
当我单击运行按钮时,它必须打开命令提示符并运行main.bat
文件,但每当我单击运行时,它什么也没说。