c#启动进程
//System.Diagnostics.Process p = new System.Diagnostics.Process();
//p.StartInfo.FileName = @"C:\Program Files (x86)\Tencent\WeChat\WeChat.exe";
//p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
//p.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
//p.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
//p.StartInfo.RedirectStandardError = true;//重定向标准错误输出
//p.StartInfo.CreateNoWindow = true;//不显示程序窗口
//p.Start();//启动程 Process[] processes = Process.GetProcesses();
foreach (Process item in Process.GetProcesses())
{
if (item.ProcessName.Contains("WeChat"))
{
item.StartInfo.FileName = @"C:\Program Files (x86)\Tencent\WeChat\WeChat.exe";
item.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
item.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
item.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
item.StartInfo.RedirectStandardError = true;//重定向标准错误输出
item.StartInfo.CreateNoWindow = true;//不显示程序窗口
item.Start();//启动程序
}
}
启动
private void StartQueueExe()
{
string filePath = AppDomain.CurrentDomain.BaseDirectory;
FileInfo file = new FileInfo(filePath);
//filePath = file.Directory.Parent.Parent.FullName + "\\ZB.QueueSystem\\ZB.QueueSystem.exe";
filePath = file.Directory.FullName + "\\ZB.QueueSystem\\ZB.QueueSystem.exe"; System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = filePath;
p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
p.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
p.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
p.StartInfo.RedirectStandardError = true;//重定向标准错误输出
p.StartInfo.CreateNoWindow = true;//不显示程序窗口
p.Start();//启动程序
}
停止
private void KillProcessExists()
{
Process[] processes = Process.GetProcessesByName("AppStart");
foreach (Process p in processes)
{
if (System.IO.Path.Combine(Application.StartupPath, "AppStart.exe") == p.MainModule.FileName)
{
p.Kill();
p.Close();
}
}
} /// <summary>
/// 关闭进程
/// </summary>
/// <param name="processName">进程名</param>
private void KillProcess(string processName)
{
Process[] myproc = Process.GetProcesses();
foreach (Process item in myproc)
{
if (item.ProcessName == processName)
{
item.Kill();
}
}
}
查看是否存在指定进程:
private bool CheckProcessExists()
{
Process[] processes = Process.GetProcessesByName("test");
foreach (Process p in processes)
{
if (System.IO.Path.Combine(Application.StartupPath, "test.exe") == p.MainModule.FileName)
return true;
}
return false;
}
c#启动进程的更多相关文章
- Linux如何查看进程、杀死进程、启动进程等常用命令
Linux如何查看进程.杀死进程.启动进程等常用命令 关键字: linux 查进程.杀进程.起进程1.查进程 ps命令查找与进程相关的PID号: ps a 显示现行终端机下的所有程序,包括 ...
- C#单独启动进程的几种方式
本文实例讲述了C#启动进程的几种常用方法.分享给大家供大家参考.具体如下: 1.启动子进程,不等待子进程结束 private void simpleRun_Click(object sender, S ...
- C# 启动进程和杀死进程
/// <summary> /// 杀死进程 /// </summary> private void KillProcesses() { var cfn = GetAppset ...
- init启动进程
init启动进程需要读取()配置文件 1,启动init进程的配置文件是/etc/inittab 2,/etc/sysvinit是系统初始化用的 /sbin/init在核心完整的加载后,开始运行系统 ...
- c#根据文件路径启动进程
//根据文件路径启动进程 private static void StartProcessByFilePath(string path) { Process p = new System.Diagno ...
- Git Extensions system.invalidoperationexception尚未提供文件名,因此无法启动进程
根据别人的博客按照步骤安装,地址如下:http://www.cnblogs.com/sorex/archive/2011/08/10/2132359.html 但是安装Git Extensions后生 ...
- 【运维】linux命令查看端口占用情况,杀死进程,后台启动进程
1.查看端口占用情况:> lsof -i:port COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ...
- 踩坑留印,启动进程遇到报错:/proc/self/fd/9: 2: ulimit: bad number
启动进程,遇到报错: /proc/self/fd/9: 2: ulimit: bad number 分析配置文件内容没有错误. 怀疑可能是文件格式问题,在IDE里面查看,果然是windows格式.ID ...
- java API Runtime 启动进程
Runtime run = new Runtime.getRuntime(); Process p = run.exec("notepad.exe F:\\lesson\\a.java&qu ...
- Android如何配置init.rc中的开机启动进程(service)【转】
本文转载自:http://blog.csdn.net/qq_28899635/article/details/56289063 开篇:为什么写这篇文章 先说下我自己的情况,我是个普通的大四学生,之前在 ...
随机推荐
- (理论篇)53个要点提高PHP编程效率
用单引号代替双引号来包含字符串,这样做会更快一些.因为php会在双引号包围的字符串中搜寻变量,单引号则不会,注意:只有echo能这么做,它是一种可以把多个字符串当作参数的"函数"( ...
- [sql server发布订阅]after触发器执行失败造成复制不成功
结论: (以插入而例) 发布端的数据插入成功 订阅段的数据不会插入 实验 创建一张新表 create table test_subscriber (id int, mark varchar(2),in ...
- 转载 sqlserver 锁的概念
SQL server共享锁,排他锁,更新锁的使用 上一篇 / 下一篇 2009-11-08 00:29:17 / 个人分类:数据库 查看( 889 ) / 评论( 0 ) / 评分( 0 / 0 ...
- PCV 学习笔记-ch1 主成分分析实现
模块名称:pca.py PCA原理与紧致技巧原理待补... #-*-coding:UTF-8-*- ''' Created on 2015年3月2日 @author: Ayumi Phoenix ch ...
- 1130-host ... is not allowed to connect to this MySql server 开放mysql远程连接 不使用localhost
报错:1130-host ... is not allowed to connect to this MySql server 解决方法: 1. 改表法. 可能是你的帐号不允许从远程登陆,只能在loc ...
- 112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all ...
- dll清理
結束了閉關,又得與人類交流了,只好裝QQ 印象中企鵝手腳一向是BAT中最乾淨的-結果還是裝了不少樂色,一併挖出來除之 C:\program files\common files\tencent\q ...
- 转 用 AXIOM 促进 XML 处理
转自:http://www.ibm.com/developerworks/cn/xml/x-axiom/ AXIOM 还不是另一种对象模型.它有着明确的设计目标:大幅提升 Apache 下一代 SOA ...
- Vigenère 密码NOIP 2012 提高组 第一天 第一题
题目描述 16 世纪法国外交家 Blaise de Vigenère 设计了一种多表密码加密算法――Vigenère 密 码.Vigenère 密码的加密解密算法简单易用,且破译难度比较高,曾在美国南 ...
- IOS中货币高精度要求使用NSDecialNumber、
float a = 0.01; int b =99999999; double c = 0.0; c = a * b; //如果单纯的使用double会导致数 ...