dongzhi6463 2012-07-10 07:31
浏览 42

从PHP调用Windows Forms .NET EXE

I've seen many posts on stackoverflow but none of them helped.

I was (am) trying to run a .NET Windows Forms application (it doesn't contain any forms/GUI/dialogs/so but because of the nature of app it has to be Windows Forms). I tried shell_exec(), exec(), passthru(), etc. but all of them failed (they take infinitely long time and PHP Script never terminates)

Then, I tried running a simple C++ (unmanaged) console application - it WORKED and returned correct output and return code.

Then, I thought, maybe I could call this C++ EXE and let it further call a Windows application (i.e. in C++ using SYSTEM("path_to_exe.exe");) It worked fine when I compiled it, but again,

when PHP calls this console (with new code to run a .NET EXE), PHP again takes infinte time and never stops. Why?

Is there any one way I can successfully run my .NET EXE on Server from PHP?

Thanks a lot!

  • 写回答

1条回答 默认 最新

  • dpkrh2444 2012-07-10 09:34
    关注

    "Is there any one way I can successfully run my .NET EXE on Server from PHP?" : Your EXE is already running !

    So the problem is in your .NET EXE, i don't know what kind of EXE it is but you may use AutoIt scripting to execute it and then close the process after X seconds, here's a snippet of code (don't forget to compile it):

    Run("C:\Program Files (x86)\K-Lite Codec Pack\Media Player Classic\mpc-hc.exe"); // You may use a relative path !
    Sleep(5000); // Wait for 5 seconds
    ProcessClose("mpc-hc.exe"); // Close the process
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
  • ¥50 invest生境质量模块