我正在尝试在WinXP上远程运行应用程序。这是代码。
void RemoteExecute(string userName,
string password,
string path,
object[] commandLine)
{
ConnectionOptions options = new ConnectionOptions();
options.Impersonation = ImpersonationLevel.Impersonate;
options.Authentication = AuthenticationLevel.Default;
options.Username = userName;
options.Password = password;
options.Authority = null;
options.EnablePrivileges = true;
ManagementScope scope = new ManagementScope(path, options);
scope.Connect();
using (ManagementClass process = new ManagementClass("Win32_Process"))
{
process.Scope = scope;
process.InvokeMethod("Create", commandLine);
}
}
...
object[] commandLine = { "cmd.exe", null, null, 0 };
RemoteExecute("acid",
"123",
@"\\192.168.142.128\Root\CIMV2",
commandLine);
然后我在scope.Connect()
:Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
上获得了例外。谷歌搜索这导致我调整目标机器上的安全设置。这就是我所做的。
administrator
。没有空密码。我还应该做些什么来避免例外?