当前位置: 首页 > news >正文

【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都可以启动进程。

http://www.lryc.cn/news/155229.html

相关文章:

  • 宝塔面板定时监控和重启MySQL数据库(计划任务)
  • Beats:安装及配置 Metricbeat (二)- 8.x
  • Redis之哨兵模式解读
  • 题目:2644.找出可整除性得分最大的整数
  • 报错:axios 发送的接口请求 404
  • 三年前端还不会配置Nginx?刷完这篇就够了
  • blender 场景灯光基础设置
  • 如何查看 SQLyog 中数据库连接信息中的密码
  • 【SpringSecurity】八、集成图片验证码
  • 【本地代码问题】启动程序,报错:java.lang.IllegalArgumentException: No selectors
  • 手写RPC框架--4.服务注册
  • oracle 解锁表
  • 使用Dbeaver连接GaussDB
  • WSL使用技巧 / 虚拟机对比
  • vuex_cart案例
  • Linux系统的安装
  • 微服务设计和高并发实践
  • 2023年高教社杯数学建模思路 - 案例:粒子群算法
  • Tomcat 集群介绍
  • Windows右键添加用 IDEA 打开
  • Golang 中return和defer执行先后顺序
  • 业务数据模拟/采集
  • qt day 5
  • Java设计模式之适配器模式
  • 每天一个工业通信协议(3)2023.8.29 (DAP接口)
  • 如何将Word转成PDF?试一下这个转换方法
  • 成都睿趣科技:现在开一家抖音小店还来得及吗
  • 原型链中:为什么Function.proto==Function.prototype?
  • 原生js实现轮播图及无缝滚动
  • MP中的字段还可以利用函数来查询拼接sql