PHP启动Windows应用程序

时间:2012-08-14 14:06:31

标签: php windows xampp

我想启动一个bat文件或exe

我试过

system("C:\\PATH\\TO\\FOLDER\\script.bat")
system("CMD.EXE C:\\PATH\\TO\\FOLDER\\script.bat")
system("C:\\PATH\\TO\\FOLDER\\exefile.exe /S nameOfFileToCreate.txt")
system("CMD.EXE C:\\PATH\\TO\\FOLDER\\exefile.exe /S nameOfFileToCreate.txt")
system("START C:\\PATH\\TO\\FOLDER\\script.bat")
system("START C:\\PATH\\TO\\FOLDER\\exefile.exe /S nameOfFileToCreate.txt")

使用START,我收到此错误消息。其他尝试会导致页面永远加载!

Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> WshShell.Exec<br/><b>Description:</b> The system cannot find the file specified. ' in C:\xampp\htdocs\upload.php:95 Stack trace: #0 C:\xampp\htdocs\upload.php(95): com->Exec('START C:\PROGRA...') #1 {main} thrown in C:\xampp\htdocs\upload.php on line 95

2 个答案:

答案 0 :(得分:1)

尝试exec功能:

http://us2.php.net/function.exec

答案 1 :(得分:0)

这没有用。无论出于何种原因,我无法启动应用程序。我决定创建一个简单的VBS脚本,然后用PHP作为临时解决方案重新启动PC