Ejemplo n.º 1
0
        public ArrayList RunningProcesses()
        {
            ArrayList alProcesses = new ArrayList();

            alProcesses = ProcessMethod.RunningProcesses(connectionScope);
            return(alProcesses);
        }
Ejemplo n.º 2
0
        public ArrayList ProcessProperties(string processName)
        {
            ArrayList alProperties = new ArrayList();

            alProperties = ProcessMethod.ProcessProperties(connectionScope,
                                                           processName);
            return(alProperties);
        }
Ejemplo n.º 3
0
        public static ArrayList ProcessProperties(ManagementScope connectionScope,
                                                  string processName)
        {
            ArrayList   alProperties = new ArrayList();
            SelectQuery msQuery      = new SelectQuery("SELECT * FROM Win32_Process Where Name = '" + processName + "'");
            ManagementObjectSearcher searchProcedure = new ManagementObjectSearcher(connectionScope, msQuery);

            foreach (ManagementObject item in searchProcedure.Get())
            {
                try { alProperties.Add("Caption: " + item["Caption"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("CommandLine: " + item["CommandLine"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("CreationClassName: " + item["CreationClassName"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("CreationDate: " + item["CreationDate"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("CSCreationClassName: " + item["CSCreationClassName"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("CSName: " + item["CSName"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("Description: " + item["Description"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("ExecutablePath: " + item["ExecutablePath"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("ExecutionState: " + item["ExecutionState"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("Handle: " + item["Handle"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("HandleCount: " + item["HandleCount"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("InstallDate: " + item["InstallDate"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("KernelModeTime: " + item["KernelModeTime"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("MaximumWorkingSetSize: " + item["MaximumWorkingSetSize"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("Memory Usage: " + ProcessMethod.TranslateMemoryUsage(item["WorkingSetSize"].ToString())); } catch (SystemException) { }
                try { alProperties.Add("MinimumWorkingSetSize: " + item["MinimumWorkingSetSize"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("Name: " + item["Name"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("OSCreationClassName: " + item["OSCreationClassName"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("OSName: " + item["OSName"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("OtherOperationCount: " + item["OtherOperationCount"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("OtherTransferCount: " + item["OtherTransferCount"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("PageFaults: " + item["PageFaults"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("PageFileUsage: " + item["PageFileUsage"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("ParentProcessId: " + item["ParentProcessId"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("PeakPageFileUsage: " + item["PeakPageFileUsage"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("PeakVirtualSize: " + item["PeakVirtualSize"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("PeakWorkingSetSize: " + item["PeakWorkingSetSize"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("Priority: " + item["Priority"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("PrivatePageCount: " + item["PrivatePageCount"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("ProcessId: " + item["ProcessId"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("QuotaNonPagedPoolUsage: " + item["QuotaNonPagedPoolUsage"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("QuotaPagedPoolUsage: " + item["QuotaPagedPoolUsage"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("QuotaPeakNonPagedPoolUsage: " + item["QuotaPeakNonPagedPoolUsage"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("QuotaPeakPagedPoolUsage: " + item["QuotaPeakPagedPoolUsage"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("ReadOperationCount: " + item["ReadOperationCount"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("ReadTransferCount: " + item["ReadTransferCount"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("SessionId: " + item["SessionId"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("Status: " + item["Status"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("TerminationDate: " + item["TerminationDate"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("ThreadCount: " + item["ThreadCount"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("UserModeTime: " + item["UserModeTime"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("VirtualSize: " + item["VirtualSize"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("WindowsVersion: " + item["WindowsVersion"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("WorkingSetSize: " + item["WorkingSetSize"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("WriteOperationCount: " + item["WriteOperationCount"].ToString()); } catch (SystemException) { }
                try { alProperties.Add("WriteTransferCount: " + item["WriteTransferCount"].ToString()); } catch (SystemException) { }
            }
            return(alProperties);
        }
Ejemplo n.º 4
0
        public static string StartProcess(string machineName, string processPath)
        {
            ManagementClass processTask = new ManagementClass(@"\\" + machineName + @"\root\CIMV2",
                                                              "Win32_Process", null);
            ManagementBaseObject methodParams = processTask.GetMethodParameters("Create");

            methodParams["CommandLine"] = processPath;
            ManagementBaseObject exitCode = processTask.InvokeMethod("Create", methodParams, null);

            return(ProcessMethod.TranslateProcessStartExitCode(exitCode["ReturnValue"].ToString()));
        }
Ejemplo n.º 5
0
 public string GetProcessOwnerSID(string processName)
 {
     return(ProcessMethod.ProcessOwnerSID(connectionScope, processName));
 }
Ejemplo n.º 6
0
 public void SetPriority(string processName, ProcessPriority.priority priority)
 {
     ProcessMethod.ChangePriority(connectionScope, processName, priority);
 }
Ejemplo n.º 7
0
 public string CreateProcess(string processPath)
 {
     return(ProcessMethod.StartProcess(Environment.MachineName, processPath));
 }
Ejemplo n.º 8
0
 public void TerminateProcess(string processName)
 {
     ProcessMethod.KillProcess(connectionScope, processName);
 }