簡體   English   中英

運行php exec()來運行可執行文件會使瀏覽器無限期地加載

[英]Running php exec() to run an executable file makes browser to load indefinitely

我正在嘗試使用PHP的exec()函數在我的AWS Windows Server 2012實例上運行exe文件來執行命令。 但它使我的瀏覽器無限期地顯示加載。 當我在服務器上執行命令時,命令運行完美。 我跑的時候

echo exec('whoami');

它返回帳戶用戶名。 所以一些命令正在通過php工作。 但是當我運行我的可執行文件時:

echo exec('myfile.exe');

它使瀏覽器繼續顯示加載。 (我已經將我的exe的路徑添加到環境變量中,以便我可以從命令提示符直接訪問我的exe)

任何幫助表示贊賞。 謝謝

我想在這里做的是,通過瀏覽器在我的服務器上打開一個exe文件。 我設法使用我在答案中找到的以下php代碼:

shell_exec('SCHTASKS /F /Create /TN _notepad /TR "notepad.exe" /SC DAILY /RU INTERACTIVE');
shell_exec('SCHTASKS /RUN /TN "_notepad"');
shell_exec('SCHTASKS /DELETE /TN "_notepad" /F');

這將在您的服務器上打開記事本。 您可以使用notepad.exe替換exe文件的路徑。這適用於Windows 8.1,Windows 10和Windows 2012 Server

您還可以嘗試以下步驟來啟用Apache服務來運行桌面應用程序:

Start->Run, type "services.msc" to bring up Services control (other ways to get there, this is easiest IMO)
Locate your Apache service (mine was called "wampapache" using WampServer 2.0)
Open the service properties (double-click or right click->properties)
Flip to the Log On account and ensure the checkbox titled "Allow service to interact with Desktop" is checked
Flip back to the General tab, stop the service, start the service

以下是我為解決方案提出的問題的鏈接: php如何啟動外部程序運行 - 遇到系統和執行錯誤

希望它可以幫助別人。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM