Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php运行批处理文件_Php_Batch File - Fatal编程技术网

使用php运行批处理文件

使用php运行批处理文件,php,batch-file,Php,Batch File,下面是我的一段代码,在输入工具名称并按submit键时,将执行该工具对应的批处理文件 <html> <head> <title>My Form</title> </head> <body> <form action="batch.php" method=post> Which tool you would like to use: <br> <inpu

下面是我的一段代码,在输入工具名称并按submit键时,将执行该工具对应的批处理文件

<html> 
   <head> 
     <title>My Form</title> 
   </head> 
 <body> 
 <form action="batch.php" method=post> 

 Which tool you would like to use:
 <br> <input type="text" name="ToolName"> 
 <p> 
 <input type="submit" name="submit" value="Please wait!">
 </form>
 </body>
 </html>

我的表格
您希望使用哪种工具:

BATCH.php

<html>
<head>
<title>Perv!</title>
</head>

<?php
$ToolName = $_REQUEST['ToolName'] ; 
?>
<p>
Hi <?php print $ToolName; 
//exec("cmd/c D:\workspace\execute.bat");
exec("C:\\wamp\\www\\test.bat");
//system("test.bat");
//system("cmd /c D:\\workspace\\execute.bat");
?>
</body>
</html>

变态!

你好
我正在使用Apache/Windows。
请建议,如有任何帮助,我们将不胜感激。

据我所知,您可以尝试以下方法:

system($ToolName);

您可能需要为$ToolName变量指定正确的路径。

正如我已经说过的,您所描述的似乎是批处理文件的问题。但是无论如何,这个文件应该只是做一些事情还是输出应该显示的东西


如果是后者,请注意
exec()
只返回输出的最后一行。您可以通过提供另一个变量来获取所有输出来获取所有输出。exec()函数的官方php告诉您必须这样做。

问题是什么?如果这不符合预期,请告诉我们预期结果,并从错误日志中粘贴任何相关输出。批处理文件实际上是HTM文件,因此这可能会以眼泪结束。既然您要导入一个简单的文本文件,为什么不使用“include”来代替呢?批处理文件包含一些未执行的Java命令。错误“线程“main”中的异常“#java”未被识别为内部或外部命令、可操作程序或批处理文件。“java”未被识别为内部或外部命令、可操作程序或批处理文件。”在我看来,这似乎是批处理文件的问题。