Пример #1
0
        /// <summary>
        /// Starts the Process.
        /// </summary>
        /// <exception cref="System.InvalidOperationException">Cannot Start Running Process.</exception>
        /// <exception cref="System.Exception">WMI command did not successfully complete</exception>
        /// <exception cref="System.ObjectDisposedException">Object Has Been Disposed</exception>
        public void Start()
        {
            if (this.IsProcessRunning)
            {
                throw new InvalidOperationException("Cannot Start Running Process.");
            }

            ManagementBaseObject outParams = this.wmiWrapper.RunCommand(this.startCommand);
            var returnCode = outParams.GetReturnValue();
            if (returnCode != WmiReturnValue.SuccessfullCompletion)
            {
                throw new Exception(string.Format("StartProcess returned: {0}.", returnCode));
            }

            this.processId = outParams.GetPid();
            this.IsProcessRunning = true;
        }