我的进程列表为什么取不出来呀?

swingero 2003-05-03 04:48:54
代码如下:
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);
}
}
}
...全文
95 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧