使用一个程序同时启动多个程序(c#)
2011-03-08 11:18
387 查看
宿舍的肥仔每次开机就需要运行多个程序,他希望一个程序实现这些事情,所以写了个程序,大家有什么意见可以给我提出来,我会多加修改,谢谢,贴上源码:
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;
using System.IO;
namespace 懒人程序
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
info.UseShellExecute = true;
Process p;
string path = @"C:\a.txt";
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs, Encoding.Default);
string rl;
while ((rl = sr.ReadLine()) != null)
{
info.FileName = rl;
//richTextBox1.AppendText(rl + '\n');
p = Process.Start(info);
}
sr.Close();
fs.Close();
Application.Exit();
}
}
}
使用说明:先安装好软件,20多K吧,运行前先在c盘根目录建立一个a.txt,然后把需要同时运行的程序详细路径,包括程序名和exe后缀,一个程序占一行,可以同时有多行,例如:
C:\Program Files\Internet Explorer\iexplore.exe
C:\Program Files\Internet Explorer\iexplore.exe
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;
using System.IO;
namespace 懒人程序
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
info.UseShellExecute = true;
Process p;
string path = @"C:\a.txt";
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs, Encoding.Default);
string rl;
while ((rl = sr.ReadLine()) != null)
{
info.FileName = rl;
//richTextBox1.AppendText(rl + '\n');
p = Process.Start(info);
}
sr.Close();
fs.Close();
Application.Exit();
}
}
}
使用说明:先安装好软件,20多K吧,运行前先在c盘根目录建立一个a.txt,然后把需要同时运行的程序详细路径,包括程序名和exe后缀,一个程序占一行,可以同时有多行,例如:
C:\Program Files\Internet Explorer\iexplore.exe
C:\Program Files\Internet Explorer\iexplore.exe
相关文章推荐
- 使用一个程序同时启动多个程序(c#)
- 使用一个程序同时启动多个程序(c#) 收藏
- 使用一个程序同时启动多个程序(c#)
- C#.NET禁止一个程序启动多个实例
- C#.NET禁止一个程序启动多个实例
- C# 1.Winform 同时修改多个config文件2.实时监测某程序运行状态(多线程),未启动时,自启。
- C#.NET禁止一个程序启动多个实例
- C#.NET禁止一个程序启动多个实例
- WinCE C#程序,控制启动时仅仅能启动一个程序,使用相互排斥量来实现,该实现方法測试通过
- C#.NET禁止一个程序启动多个实例
- C#.NET禁止一个程序启动多个实例
- C#.NET禁止一个程序启动多个实例
- C#启动一个外部程序(方法1) - WinExec
- 重新想象 Windows 8 Store Apps (33) - 关联启动: 使用外部程序打开一个文件或uri, 关联指定的文件类型或协议
- C#中如何使用Process.Start()使一个无gui的exe应用程序在后台启动
- C#程序多用户只启动一个进程的方法
- C#创建服务及使用程序自动安装服务,.NET创建一个即是可执行程序又是Windows服务的exe
- 用C#给程序加启动画面并只允许一个应用程序实例运行
- C#启动一个外部程序(3)-CreateProcess
- 用C#给程序加启动画面并只允许一个应用程序实例运行