Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="commands"></param>
        public static void RunCommands(string commands)
        {
            if (string.IsNullOrEmpty(commands))
            {
                return;
            }
            List <CommandWrapper> cmds = CommandWrapper.Parse(commands);

            foreach (CommandWrapper command in cmds)
            {
                Process p = new Process();
                p.StartInfo = new ProcessStartInfo(command.Command, command.Arguments);
                p.StartInfo.CreateNoWindow  = true;
                p.StartInfo.UseShellExecute = false;
                p.Start();
                p.WaitForExit();
            }
        }
Пример #2
0
        public static List <CommandWrapper> Parse(string commands)
        {
            List <CommandWrapper> list = new List <CommandWrapper>();

            if (string.IsNullOrEmpty(commands))
            {
                return(list);
            }
            string[] arr = commands.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var s in arr)
            {
                string         ss = s.Trim();
                string[]       ca = ss.Split(new[] { '\t' }, 2);
                CommandWrapper cw = new CommandWrapper {
                    Command = ca[0], Arguments = ca.Length > 1 ? ca[1] : null
                };
                list.Add(cw);
            }
            return(list);
        }