【C#】C#调用进程打开一个exe程序


一、过程

新建WinForm程序,并写入代码,明确要调用的程序的绝对路径(或相对路径)下的exe文件。
在这里插入图片描述

调用代码:
这里我调用的另一个程序的路径是:

F:\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.exe

你可以把这个路径改成你自己要调用的程序的路径。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (System.IO.File.Exists(@"F:\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.exe"))
            {
                System.Diagnostics.Process.Start(@"F:\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.exe");    
            }
        }
    }
}

二、效果

运行起来,点击按钮1,也可以同时调用多个exe

在这里插入图片描述

调用的exe程序运行起来:

在这里插入图片描述


总结

可以调用的程序可以不是C#程序,可以是其他应用程序,例如windows自带的一些工具,或者其他语言做的程序,只要是exe都可以启动进程。

  • 0
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值