【问题标题】:Call Process.GetProcesses by specifying/impersonating another account?通过指定/模拟另一个帐户来调用 Process.GetProcesses?
【发布时间】:2012-05-14 06:38:15
【问题描述】:

通过Process.GetProcesses,我们可以列出远程计算机中正在运行的进程,例如

Process [] allRemoteProcesses = Process.GetProcesses("myRemoteComputer");

但是,这似乎取决于我的帐户的许可。它抛出异常“无法连接到远程机器”。如果正在运行的用户无权访问远程计算机。我可以在检查进程时指定另一个由 .NET 使用的帐户,类似于PsList 中的-u-p 开关吗?

【问题讨论】:

    标签: c# .net sysinternals


    【解决方案1】:

    我之前所做的是使用类似于this article 中描述的内容。

    using (new Impersonator("user", "domain", "pass"))
    {
       Process[] allRemoteProcesses = Process.GetProcesses("myRemoteComputer");
       // Rest of code...
    }
    

    另一种方法是使用 WMI 并像here 中描述的那样查询进程。

    【讨论】:

      【解决方案2】:

      对于同样的问题,在远程注册表中打开远程注册表服务对我有用!

      【讨论】:

        猜你喜欢
        • 2011-08-10
        • 2021-01-09
        • 2020-05-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-02-19
        相关资源
        最近更新 更多