从php运行.cmd或.bat文件? [英] Run .cmd or a .bat file from php?
本文介绍了从php运行.cmd或.bat文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
场景:
在C:\ TestSolder \中有两个文件
- > Batch.bat
- > Command.cmd
问题:
我如何运行这些文件?
到目前为止我尝试了什么并且失败了
Scenario:
Have two files in "C:\TestFolder\"
->Batch.bat
->Command.cmd
Question:
How do i run these files?
What i tried so far and failed
Method1
$shell = new COM("WScript.Shell") or die("Requires Windows Scripting Host");
$exePath = ("C:\TestFolder\Batch.bat");//also tried Command.cmd
$shell->exec($exePath);
Method2
$result = `C:\TestFolder\Batch.bat`;//also tried Command.cmd
Method3
exec("C:\TestFolder\Batch.bat", &$Result);//also tried Command.cmd
Method4
system("cmd /c C:\TestFolder\Batch.bat");//also tried Command.cmd
推荐答案
shell = new COM( WScript.Shell )或 die( 需要Windows Scripting H OST跨度>);
shell = new COM("WScript.Shell") or die("Requires Windows Scripting Host");
exePath =( C:\ TestSolder \Batch.bat); // 还试过Command.cmd
exePath = ("C:\TestFolder\Batch.bat");//also tried Command.cmd
shell-> exec(
shell->exec(
这篇关于从php运行.cmd或.bat文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文