コード例 #1
0
        public ProcessLauncher(string procPath, string procArgs, // required
                               string avoidProcName = "", int delayTime     = 0, bool elevate = false,
                               int avoidPID         = 0, string monitorName = "")
        {
            ProcWrapper   = new ProcessWrapper();
            ExecPath      = procPath;
            ExecArgs      = procArgs;
            AvoidProcName = avoidProcName;
            Delay         = delayTime;
            Elevated      = elevate;
            MonitorName   = monitorName;
            AvoidPID      = avoidPID;

            // construct and save our ProcessWrapper
            if (SettingsData.ValidatePath(ExecPath) ||
                SettingsData.ValidateURI(ExecPath))
            {
                Process _procObj = new Process();
                _procObj.StartInfo.UseShellExecute = true;
                _procObj.StartInfo.FileName        = ExecPath;
                _procObj.StartInfo.Arguments       = ExecArgs;
                if (!SettingsData.ValidateURI(ExecPath))
                {
                    _procObj.StartInfo.WorkingDirectory = Directory.GetParent(ExecPath).ToString();
                }
                if (Elevated)
                {
                    _procObj.StartInfo.Verb = "runas";
                }
                // bind our process wrapper
                ProcWrapper = new ProcessWrapper(_procObj,
                                                 avoidPID: AvoidPID,
                                                 altName: MonitorName,
                                                 avoidProcName: AvoidProcName
                                                 );
            }
        }