命令行启动软件

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace run3
{
    class Program
    {
        static void Main(string[] args)
        {

            if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)+"\\run.ini")) {
                Console.WriteLine("no run.ini");
                return;
            }
            if (args.Length == 0) return;
            StreamReader sw = File.OpenText(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\run.ini");
            String temp = "-";
            String all = "";
            
            while ((temp = sw.ReadLine()) != null)
            {
                if (temp == "") continue;
                if (args[0] == temp.Split(new String[] { "=" }, StringSplitOptions.RemoveEmptyEntries)[0])
                {
                    try
                    {

                        Process.Start(temp.Split(new String[] { "=" }, StringSplitOptions.RemoveEmptyEntries)[1]);
                    }
                    catch(Win32Exception e)
                    {

                    }


                    
                }
                

            }

            sw.Close();










        }
    }
}

  

posted @ 2016-08-26 12:14  Ali.Blacken  阅读(210)  评论(0)    收藏  举报