Exemplo n.º 1
0
        /// <summary>
        /// Query 'ps' command for a list of processes
        /// </summary>
        private bool PSListProcess(string username, out string errorMessage, out List <Process> processes)
        {
            errorMessage = string.Empty;
            string commandOutput;
            int    exitCode;

            if (!ExecuteCommand(PSOutputParser.PSCommandLine, Timeout.Infinite, false, out commandOutput, out errorMessage))
            {
                // Clear output and errorMessage
                commandOutput = string.Empty;
                errorMessage  = string.Empty;
                if (!ExecuteCommand(PSOutputParser.AltPSCommandLine, Timeout.Infinite, false, out commandOutput, out errorMessage, out exitCode))
                {
                    if (exitCode == 127)
                    {
                        //command doesn't Exist
                        errorMessage = StringResources.Error_PSMissing;
                    }
                    else
                    {
                        errorMessage = StringResources.Error_PSErrorFormat.FormatCurrentCultureWithArgs(exitCode, errorMessage);
                    }

                    processes = null;
                    return(false);
                }
            }

            processes = PSOutputParser.Parse(commandOutput, username);
            return(true);
        }
Exemplo n.º 2
0
        internal List <PSOutputParser.Process> ListProcesses()
        {
            var command = _remoteSystem.Shell.ExecuteCommand(PSOutputParser.CommandText);

            if (command.ExitCode != 0)
            {
                throw new CommandFailedException(StringResources.Error_PSFailed);
            }

            return(PSOutputParser.Parse(command.Output));
        }
Exemplo n.º 3
0
        public override List <Process> ListProcesses()
        {
            string username;

            TryGetUsername(out username);

            string commandOutput;

            if (!ExecuteCommand(PSOutputParser.PSCommandLine, Timeout.Infinite, false, out commandOutput))
            {
                if (!ExecuteCommand(PSOutputParser.AltPSCommandLine, Timeout.Infinite, false, out commandOutput))
                {
                    throw new CommandFailedException(StringResources.Error_PSFailed);
                }
            }

            return(PSOutputParser.Parse(commandOutput, username));
        }