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 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题