使用一個程序同時啓動多個程序(c#)

宿舍的肥仔每次開機就需要運行多個程序,他希望一個程序實現這些事情,所以寫了個程序,大家有什麼意見可以給我提出來,我會多加修改,謝謝,貼上源碼:
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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章