问题
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