【发布时间】:2012-08-10 20:22:50
【问题描述】:
我想启动一个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
【问题讨论】:
-
另请注意,如果路径包含空格,您可能需要引用路径(鉴于错误消息中报告的路径,我猜它确实如此)。比如:
system("start \"C:\\Path with spaces\\program.exe\""); -
我使用了 C:\PROGRA~1\MICRO~2\ 这样的短路径,而不是长路径