1

我想杀死远程计算机上的 com 进程。

我尝试了 taskkill,但我找不到如何从 com guid 或启动参数中获取 pid。

然后我尝试了以下操作:

ConnectionOptions connectoptions = new ConnectionOptions();
connectoptions.Username = @"YourDomainName\UserName";
connectoptions.Password = "Password";

ManagementScope scope = new ManagementScope(@"\\" + remoteComp + @"\root\cimv2", connectoptions);

//Define the WMI query to be executed on the remote machine
SelectQuery query = new SelectQuery("select * from Win32_process where name = 'dllhost.exe' and CommandLine LIKE '%COMGUID%'");

using (ManagementObjectSearcher searcher = new
                   ManagementObjectSearcher(scope, query))
{
    foreach (ManagementObject process in searcher.Get())
    {

        process.InvokeMethod("Terminate", null);

    }
}

出于某种原因,由于 RPC 错误(防火墙已关闭),我无法执行它

我把它放在自己的 Web 服务中,但我得到“用户凭据不能用于本地连接”

我删除了 ConnectionOptions 但我仍然无法执行它,因为我得到 CommandLine 始终为空并且我无法确定正确的 dllhost.exe 实例。

我在 web 服务中使用了 Process 类,但 sturtupinfo 参数始终为空。

如何获取不同进程的 stutup 参数,或者是否有任何方法来终止进程。

4

0 回答 0