简体   繁体   English

在具有模拟C#的远程计算机上启动进程

[英]Lauch a process on a remote machine with impersonation c#

I'm trying to launch a process using impersonation with WMI and C#. 我正在尝试使用WMI和C#进行模拟启动过程。

Here's what I have so far: 这是我到目前为止的内容:

var coptions = new ConnectionOptions();
coptions.Username = String.Format(@"{0}\{1}", machine.Domain, machine.Username);
coptions.Password = machine.Password;
coptions.Impersonation = ImpersonationLevel.Impersonate;
coptions.EnablePrivileges = true;


var mScope = new ManagementScope(String.Format(@"\\{0}\root\cimv2", machine.Address), coptions);
var mClass = new ManagementClass(mScope, new ManagementPath("Win32_Process"), new ObjectGetOptions());
object[] generatorProcess = { @"C:\test\test1.exe" };
mClass.InvokeMethod("Create", generatorProcess);

Exception: 例外:

E_ACCESSDENIED at mClass.InvokeMethod 在mClass.InvokeMethod处E_ACCESSDENIED

How can I do it? 我该怎么做?

PS: The user I'm launching the process with does not have admin privileges, is it required? PS:我用来启动进程的用户没有管理员权限,这是必需的吗?

EDIT: It works with an admin, looks like it's the user.. 编辑:它与管理员一起使用,看起来像是用户。

I've followed this guide here to try and give permissions without sucess. 我已按照本指南尝试在没有成功的情况下授予权限。 https://support.infosim.net/demo/wmi/wmi.html https://support.infosim.net/demo/wmi/wmi.html

Help please 请帮助

Basically, you can't do it with an account that has limited permissions. 基本上,您不能使用具有受限权限的帐户来执行此操作。 You can tweak the permissions on the WMI object to read but not to write it does not work at all. 您可以调整WMI对象的权限以读取但不能写入,这根本不起作用。

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

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