Process Information on Remote Computer

无人久伴 提交于 2019-12-25 03:54:20

问题


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. 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?


回答1:


To perform remote administration functions, usually, the right answer is to use WMI.

  • Win32_Process class for process information.
  • Win32_Service class for services.

And using types in System.Management to interact with WMI from .NET. This page includes a simple example.

I would suggest using WMI for both remote and local information—avoiding two sets of code to maintain.




回答2:


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

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.

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. 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.



来源:https://stackoverflow.com/questions/6476143/process-information-on-remote-computer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!