using windows forms execute a .exe file

送分小仙女□ 提交于 2021-02-10 16:21:41

问题


I want to execute a .exe file which starts my node.js app using windows forms(vb.net) on a button click. I am using

    Process.Start("C:\Users\PROG21\Desktop\chat\start.exe")

The problem is it starts the command window and just within 3-4 seconds it automatically closes.Why is that so? This is happening only with Node.js app ,the other .exe files run smoothly through this code.

And also on other button click i want to close the command window terminating the Node.js app.How can i achieve it?

Any help would be appreciated

Cheers Jeev


回答1:


The difference is that you used the command interpreter to get it started from the command line. Which keeps the window opened after the program terminates. That doesn't happen when you start it from your own program.

Change the Process.Start() call like this:

Process.Start("cmd.exe", "/k C:\Users\PROG21\Desktop\chat\start.exe")

The /k option keeps the console window opened after the program completes.



来源:https://stackoverflow.com/questions/14001922/using-windows-forms-execute-a-exe-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!