c# 关闭和重启.exe程序
Process[] myprocess = Process.GetProcessesByName("a");
if (myprocess.Count() > 0)//判断如果存在
{
//myprocess[0].Kill();//关闭程序
}
else
{
try
{
Process newProcess = new Process();//创建一个新的进程
ProcessStartInfo startInfo = new ProcessStartInfo();//启动进程时使用的集合
//startInfo.FileName = Environment.CurrentDirectory + "\\Release1\\a.exe";//要启动的应用程序
startInfo.FileName = "E:\\work\\Release\\a.exe";//要启动的应用程序
startInfo.WindowStyle = ProcessWindowStyle.Normal;//启动应用程序时使用的窗口状态
//startInfo.WorkingDirectory = Environment.CurrentDirectory + "\\Release1\\";//要启动应用程序的路径
newProcess.StartInfo = startInfo;//把启动进程的信息赋值给新建的进程
newProcess.StartInfo.UseShellExecute = false;//是否使用操作系统shell执行该程序
newProcess.Start();
}
catch
{
//退出控制台程序
Application.Exit();
}
c# 关闭和重启.exe程序的更多相关文章
- C# 重启exe
休夸此地分天下 c# 关闭和重启.exe程序 Process[] myprocess = Process.GetProcessesByName("a"); )//判断如果存在 { ...
- WPF 程序中启动和关闭外部.exe程序
当需要在WPF程序启动时,启动另一外部程序(.exe程序)时,可以按照下面的例子来: C#后台代码如下: using System; using System.Collections.Generic; ...
- windows系统定时重启自定义exe程序
工作需要, Windows系统定时重启自定义exe程序. 写了如下程序, 按照说明(readme.txt)修改批处理文件中的四个参数即可: 1.readme.txt 第一个参数:进程名(不用带exe) ...
- 批处理+VBS+注册表实现开机自动启动EXE程序
批处理+VBS+注册表实现WINDOWS开机自动启动EXE程序 以下都是基于WINDOWS系统. 我们都知道当我们有想某个程序在开机时自动运行,只能有三个方式: 1.做成服务,然后对服务进行配置为自动 ...
- Linux,在不使用U盘的情况下使用wubi.exe程序在Win7上安装ubuntu-14.04.3版系统
本文介绍如何在不使用U盘的情况下使用wubi.exe程序在Win7上安装ubuntu-14.04.3版系统. 花了一天的时间终于安装上了Ubuntu14.04,过程坎坷,是血泪史,开始报“cannot ...
- 【点滴积累,厚积薄发】windows schedule task中.exe程序的路径问题等问题总结
1.在发布ReportMgmt的Job时遇到一个路径问题,代码如下: doc.Load(@"Configuration\Business\business.config"); ...
- Asp.Net 之 通过调用 WScript.Shell 启动本地 exe 程序时产生“ automation服务器不能创建对象 ”的错误
我们经常需要通过生成 ActiveXObject("WScript.Shell"); 来调用某一exe文件. 设置网页打印的页眉页脚为空: var HKEY_Root,HKEY_P ...
- Linux 关闭及重启方式
一.shutdown 命令 作用:关闭或重启系统 使用权限:超级管理员使用 常用选项 1. -r 关机后立即重启 2. -h关机后不重启 3. -f快速关机,重启时跳过fsck(file system ...
- 使用Advanced Installer将.exe程序重新封装为.msi程序
原文:使用Advanced Installer将.exe程序重新封装为.msi程序 使用Advanced Installer将.exe程序重新封装为.msi程序 首先安装Advanced instal ...
随机推荐
- leetcode1020
class Solution(object): def __init__(self): self.cons = 0 self.S = list() def dfs(self,m,n,v,A): whi ...
- leetcode212
class Solution { public List<String> findWords(char[][] board, String[] words) { List<Strin ...
- SpringBoot配置swagger2(亲测有效,如果没有配置成功,欢迎在下方留言)
一.导包: <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swa ...
- vue 设置背景
<span :style="{ 'background': 'url(' + aboutImg1 + ') no-repeat center center', 'background- ...
- Dockerfile构建MySQL
转自:https://www.cnblogs.com/jsonhc/p/7807931.html 利用Dockerfile自定义构建MySQL服务折腾了几天,一直在启动服务上出现错误,现在终于解决了该 ...
- SED命令用法整理
sed '/Started/'q 匹配到Started字符串则退出sed命令 sed '/Started/{/in/q}' 同时匹配到Started和in两个字符时则退出sed命令 ------- ...
- 在CentOS7中利用yum命令安装mysql
在CentOS7中利用yum命令安装mysql 原创 2016年08月31日 10:42:33 标签: mysql / centos 4832 一.说明 我们是在VMware虚拟机上安装的mysql, ...
- 如何使用JDBC查询所有记录
public class JdbcDao { private Connection conn=null; //数据库连接对象 private String strSql=null; / ...
- springboot 引入 thymeleaf 模板
第一步pom中: <!-- 引入 thymeleaf 模板依赖 --> <dependency> <groupId>org.springframework.boot ...
- js(鼠标键盘拖动事件)
拖动事件是h5(HTML5的) 1:draggable(true) 2:拖动源 ondragstart ,ondragend 3:目的地 ondraglenter,ondragover,ondragl ...