예제 #1
0
        private string parse_generic(CustomButton customButton, string parameters)
        {
            Match match = Regex.Match(parameters,
                                      @"^(\s*([sS]end|[rR]un(?:[aA]s[aA]dmin|[sS]ilent)?)\(([^\)]+)\)\s*)+$");
            string error_message = "";

            if (match.Success)
            {
                for (int i = 0; i < match.Groups[2].Captures.Count; i++)
                {
                    switch (match.Groups[2].Captures[i].Value)
                    {
                    case "Send":
                    case "send":
                        error_message = parse_Send(customButton, match.Groups[3].Captures[i].Value);
                        if (error_message != "")
                        {
                            return(error_message);
                        }
                        break;

                    case "Run":
                    case "run":
                        error_message = parse_Run(customButton, match.Groups[3].Captures[i].Value, Process_type.Normal);
                        if (error_message != "")
                        {
                            return(error_message);
                        }
                        break;

                    case "RunAsAdmin":
                    case "RunasAdmin":
                    case "RunAsadmin":
                    case "Runasadmin":
                    case "runAsAdmin":
                    case "runasAdmin":
                    case "runAsadmin":
                    case "runasadmin":
                        error_message = parse_Run(customButton, match.Groups[3].Captures[i].Value, Process_type.Admin);
                        if (error_message != "")
                        {
                            return(error_message);
                        }
                        break;

                    case "RunSilent":
                    case "Runsilent":
                    case "runSilent":
                    case "runsilent":
                        error_message = parse_Run(customButton, match.Groups[3].Captures[i].Value, Process_type.Silent);
                        if (error_message != "")
                        {
                            return(error_message);
                        }
                        break;

                    default: throw new NotImplementedException();
                    }
                }
                return(error_message);
            }
            else
            {
                return("Performer [" + customButton.Text + "] — Syntax error in generic command");
            }
        }