c# 打开exe文件与关闭exe文件 c#服务打开exe时候默认是没有窗体界面的
来源:互联网 发布:用友票据打印软件 编辑:程序博客网 时间:2024/05/21 10:53
原文地址:http://blog.csdn.net/2004v2004/archive/2009/03/21/4012650.aspx
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
private static System.Diagnostics.Process LandEatSnake, LandFileDivisison;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)// 打开exe
{
try
{
if (LandFileDivisison == null)
{
LandFileDivisison = new System.Diagnostics.Process();
LandFileDivisison.StartInfo.FileName = "1.exe";
LandFileDivisison.Start();
}
else
{
if (LandFileDivisison.HasExited) //是否正在运行
{
LandFileDivisison.Start();
}
}
}
catch (Exception err)
{
MessageBox.Show("运行程序出错!" + err.ToString(), "出错信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button2_Click(object sender, EventArgs e) //关闭exe
{
Process[] pProcess;
pProcess = Process.GetProcesses();
for (int i = 1; i <= pProcess.Length - 1; i++)
{
if (pProcess[i].ProcessName == "1") //任务管理器 应用程序的名
{
pProcess[i].Kill();
break;
}
}
}
}
}
c#服务打开exe时候默认是没有窗体界面的
解决办法 是“点这个服务” “右键”--” 属性“ “登陆” 选择 “允许服务与桌面交互” 即可
try
{
if (LandFileDivisison == null)
{
LandFileDivisison = new System.Diagnostics.Process();
LandFileDivisison.StartInfo.FileName = strfilename;// "C://Temp//server.exe"; //换成你要执行的
LandFileDivisison.StartInfo.UseShellExecute = false;
LandFileDivisison.StartInfo.RedirectStandardInput = true;
LandFileDivisison.StartInfo.RedirectStandardOutput = true;
LandFileDivisison.StartInfo.RedirectStandardError = true;
LandFileDivisison.StartInfo.CreateNoWindow = true;
// LandFileDivisison.StartInfo.Arguments = "strdbname"; //传参数 打开exe
string strregvalue = strdbname +"," + struser + "," + strpassword + "," + strskyip + "," + strskyport;
WriteLog_text.WriteToLog("注册表数据 " + strregvalue + "/r/n");
LandFileDivisison.StartInfo.Arguments = strregvalue;
LandFileDivisison.Start();
WriteLog_text.WriteToLog("EXE" +"启动成功" + "/r/n");
}
else
{
if (LandFileDivisison.HasExited) //是否正在运行
{
LandFileDivisison.Start();
}
}
}
catch (Exception err)
{
WriteLog_text.WriteToLog("!" + err.ToString() + "启动成功" + "/r/n");
// MessageBox.Show("运行程序出错!" + err.ToString(), "出错信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/2004v2004/archive/2009/03/21/4012650.aspx
- c# 打开exe文件与关闭exe文件 c#服务打开exe时候默认是没有窗体界面的
- c# 打开exe文件与关闭exe文件 c#服务打开exe时候默认是没有窗体界面的
- C# 打开exe文件
- c# 程序 打开 文件,.exe等
- c# 打开其他EXE
- Java打开exe文件
- exe文件无法打开
- UE4 打开EXE文件
- Unity打开.exe文件
- 如何恢复windows的exe文件的默认打开方式
- C#打开运行exe程序
- c# 打开外部可执行文件exe。
- c#启动EXE文件
- C#启动exe文件
- ShellExecuteEx打开、关闭exe
- JavaScript打开客户端exe文件~
- JavaScript打开客户端exe文件
- asp调用打开exe文件
- Oracle中多表查询再按时间倒序
- Java高级技术 5.8 运行期类型检查 已经更新
- Formatting Types
- 计算机图形学—判断点在直线上的方法
- 2440从sd卡启动wince
- c# 打开exe文件与关闭exe文件 c#服务打开exe时候默认是没有窗体界面的
- 初识MFC
- eclipse下安装ve
- Java 几种排序法
- 数据字典
- 飞鸽传书mayfish 数据入库验证
- 收藏网址
- gridview 隐藏某一列
- Tokyo Tyrant(TTServer)系列-备份恢复和增加从库