简体   繁体   English

远程计算机上的过程信息

[英]Process Information on Remote Computer

I am writing a small program to retrieve list of services and processes running on a remote computer, all is running well. 我正在编写一个小程序来检索在远程计算机上运行的服务和进程列表,一切运行良好。 I am using Process for ret list of processes and ServiceController for list of services. 我使用Process for ret列表进程和ServiceController用于服务列表。 Now is there anyway to get the size of the processes that are running on remote pc and actually find the size of the file associated with the process? 现在有没有获得在远程PC上运行的进程的大小,并实际找到与进程关联的文件的大小?

The tasklist and taskview functionality on command prompt could also aid in doing this. 命令提示符下的任务列表和任务视图功能也可以帮助完成此操作。 Your program could run cmd.exe in a process object and enter 您的程序可以在进程对象中运行cmd.exe并输入

tasklist /s remoteServer /u userName

as input, then listen to the output. 作为输入,然后听取输出。 It'll ask for a password for the account which should be provided as the next input. 它会要求提供该帐户的密码,该密码应作为下一个输入提供。 You could then listen for successive outputs till the EndOfOutput is reached. 然后,您可以监听连续输出,直到达到EndOfOutput。

Or if you have access to the remote computer, you could write a windows form program or console application hosting a WCF Service with a method that returns the list of running processes using Process.GetProcesses(), which would be executing on the remote computer. 或者,如果您可以访问远程计算机,则可以使用Process.GetProcesses()返回正在运行的进程列表的方法编写承载WCF服务的Windows窗体程序或控制台应用程序,该方法将在远程计算机上执行。 Using a service client in your program, you could call the remote method. 在程序中使用服务客户端,可以调用远程方法。

Any of the two above would work without having to use WMI, i guess. 我想,上面两个中的任何一个都可以在不使用WMI的情况下工作。

To perform remote administration functions, usually, the right answer is to use WMI. 要执行远程管理功能,通常,正确的答案是使用WMI。

And using types in System.Management to interact with WMI from .NET. 并使用System.Management类型与.NET中的WMI进行交互。 This page includes a simple example. 此页面包含一个简单示例。

I would suggest using WMI for both remote and local information—avoiding two sets of code to maintain. 我建议将WMI用于远程和本地信息 - 避免维护两组代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM