使用windows窗体执行一个.exe文件 [英] using windows forms execute a .exe file

查看:42
本文介绍了使用windows窗体执行一个.exe文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行一个 .exe 文件,该文件在单击按钮时使用 windows 窗体(vb.net)启动我的 node.js 应用程序.我正在使用

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")

问题是它启动命令窗口并在 3-4 秒内自动关闭.为什么会这样?这仅在 Node.js 应用程序中发生,其他 .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.

还有点击其他按钮,我想关闭终止 Node.js 应用程序的命令窗口.我该如何实现?

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

任何帮助将不胜感激

干杯杰夫

推荐答案

不同之处在于您使用命令解释器从命令行启动它.在程序终止后保持窗口打开.当您从自己的程序启动它时不会发生这种情况.

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.

像这样更改 Process.Start() 调用:

Change the Process.Start() call like this:

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

/k 选项在程序完成后保持控制台窗口打开.

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

这篇关于使用windows窗体执行一个.exe文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆