.NET - 获取在另一个域中的计算机上运行的进程
我正在寻找一种方法,从 .NET 代码中获取远程计算机上正在运行的进程列表,该计算机位于不同的域中。
我有机器的用户名和密码。但是,System.Diagnostics.Process.GetProcesses() 函数只有两个重写。其中之一接受远程计算机的名称,但无法将用户名和密码发送到该计算机。为了让 punciton 工作,它必须是您域中您已经有权访问的计算机。
我不能 100% 确定这是否可以完成,但我怀疑可以通过 Interop 和 WMI 来完成。
如果重要的话,.NET 应用程序正在 Windows 7 监控计算机上运行,该计算机需要连接到我们零售地点之一的 Windows XP 计算机。
在发布这个问题之前,我尝试过搜索以前的问题并尝试谷歌。如果存在重复的问题,请告诉我,我将删除该问题。
I am looking for a way, from .NET code, to get the list of running processes on a remote machine, which is on a different domain.
I have the username and password for the machine. However, the System.Diagnostics.Process.GetProcesses() function only has two overrides. One of them accepts a remote machine's name, but no way to send the username and password to that machine. In order for the punciton to work, it would have to be a machine on your domain that you already have access to.
I'm not 100% sure if this can be done, but I suspect it could be done via Interop and WMI.
If it matters, the .NET app is running on a Windows 7 monitoring machine that needs to connect to a Windows XP machine out in one of our retail locations.
I have tried searching for previous questions and tried Google before posting this question. If there is a duplicate question out there, please let me know and I'll delete this question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我讨厌回答自己的问题,但对于下一个人面临这个挑战,我确实找到了一种通过 System.Management 对象更简单的方法来做到这一点。
codeproject.com 上有一个带有源代码的完整工作应用程序。
http://www.codeproject.com/KB/cs/Remote_process_controller.aspx
为了我的特定目的,我对它进行了相当多的修改,并获得了尽可能小的功能来做到这一点。我正在与下一个人分享它。
请注意,您需要将对 System.Management 的引用添加到您的项目中。
I hate answering my own questions, but for the next person to face this challenge, I did find an easier way to do this via the System.Management objects.
There's a full working application with source code at codeproject.com.
http://www.codeproject.com/KB/cs/Remote_process_controller.aspx
I modified it quite a bit for my specfic purpose, and got the smallest possible funciton to do this. I'm sharing it for the next person to come along.
Note, that you will need to add a reference to System.Management to your project.
您正在寻找的是实现与 runas /networkonly 等效的方法,其中本地计算机上的进程标识保持不变,而任何出站网络访问都是使用指定的凭据完成的。
根据 SO 帖子 如何将 RUNAS /NETONLY 功能构建到 (C#/.NET/WinForms) 程序中? 您需要使用
CreateProcessWithLogonW
LOGON_NETCREDENTIALS_ONLY
。What you are looking for is implementing an equivalent to
runas /networkonly
where the process identity on the local machine is unchanged, while any outbound network access is done using specified credentials.According to an SO post How to build RUNAS /NETONLY functionality into a (C#/.NET/WinForms) program? you need to use
CreateProcessWithLogonW
withLOGON_NETCREDENTIALS_ONLY
.您可以尝试这个 工具 ,它完全满足您的要求。您可以从任何域监控远程计算机。该工具允许监控远程机器进程、安装的软件、设备、服务、会话等...
You could try this tool , which exactly fulfills your requirement. You could monitor remote computers from any domain. This tool allows to monitor the remote machine processes, installed software, devices, services, sessions, etc...