我的进程列表为什么取不出来呀?
代码如下:
using System;
using System.Diagnostics;
using System.Windows.Forms;
class GetProcessesByNameClass
{
public static void Main(string[] args)
{
try
{
Console.Write("Create report processes on server \n");
// Console.Write("Enter Remote Machine Name : ");
//string remoteMachineName = Console.ReadLine();
// Get all notepad processess into Process array.
Process[] myProcesses = Process.GetProcessesByName("report");(这行根本执行不了)
if(myProcesses.Length == 0)
{
Console.WriteLine("Could not find report processes on remote machine");
Process p = new Process();
p.StartInfo.RedirectStandardOutput=false;
p.StartInfo.FileName="e:\\report\\report.exe";
p.StartInfo.UseShellExecute=true;
p.Start();
p.WaitForExit();
p.Dispose();
}
foreach(Process myProcess in myProcesses)
{
Console.Write("Process Name : " + myProcess.ProcessName + " Process ID : "
+ myProcess.Id + " MachineName : " + myProcess.MachineName + "\n");
}
}
catch(SystemException e)
{
Console.Write("Caught Exception .... : " + e.Message);
}
catch(Exception e)
{
Console.Write("Caught Exception .... : " + e.Message);
}
}
}