点击按钮-->启动 *.exe 文件

发布于 2024-08-28 22:04:46 字数 150 浏览 3 评论 0原文

基本上,我想要做的是当我单击按钮时启动 *.exe 文件。我想在 VB.NET 中完成此操作。我有 Microsoft Visual Basic 2008 Express 版本。

我的按钮称为“btnYES”。

如何通过单击此按钮启动 *.exe 文件?

Basically, what I want to do is launch an *.exe file when I click on a button. I want this done in VB.NET. I have Microsoft Visual Basic 2008 Express Edition.

The button I have is called 'btnYES'.

How can I launch an *.exe file from the click of this button?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小梨窩很甜 2024-09-04 22:04:47

在按钮调用的事件处理程序中,

Process.Start("C:\path_to\myapp.exe")

您可以在 MSDN 文档中找到更多示例 <代码>Process.Start()

如果您不知道如何创建事件处理程序:只需在设计器中打开表单并双击 btnYes 按钮即可。这将自动为按钮单击事件创建一个事件处理程序,并且 IDE 将在正确的位置为您打开代码文件。

In the event handler of the button call

Process.Start("C:\path_to\myapp.exe")

You will find further samples in the MSDN documentation for Process.Start().

In case you don't know how an event handler is created: Simply open the form in the designer and double-click on the btnYes button. This will automatically create an event handler for the button click event and the IDE will open the code file for you at the correct position.

薄荷港 2024-09-04 22:04:47

如果您想通过代码调用 exe 文件:

  1. 如果该文件是单个文件,请执行以下操作:

    Process.Start("D:\MATI2\MATI.EXE")
    

右键单击 exe 文件,同时按 Shift 键并选择复制为路径,即可获取路径

  1. 如果文件依赖于一个或多个.dll 文件以前的方法不起作用,请使用以下方法:

    将信息调暗为新的 ProcessStartInfo()
    info.FileName = "C:\Program Files (x86)\VentSrv\ventrilo_srv.exe"
    info.WorkingDirectory = "C:\Program Files (x86)\VentSrv"
    info.Arguments = "<如有必要,请在此处指定命令行参数>"
    进程.开始(信息)
    

If you want to call an exe file by code:

  1. If the file is a single file do the following:

    Process.Start("D:\MATI2\MATI.EXE")
    

You can obtain the path by right click the exe file while pressing shift and choosing copy as path

  1. If the file is dependent on one or more .dll files the previous way will not work, use the following:

    Dim info As New ProcessStartInfo()
    info.FileName = "C:\Program Files (x86)\VentSrv\ventrilo_srv.exe"
    info.WorkingDirectory = "C:\Program Files (x86)\VentSrv"
    info.Arguments = "<specify the command line arguments here if necessary>"
    Process.Start(info)
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文