[英]WMI Access Denied
我创建了一个只有一个任务的小型应用程序。 这是为了获取远程计算机的信息。 它可以在发布和调试模式下很好地工作。 当我在“ .net核心”项目中使用它时,应用程序将显示“拒绝访问”错误。
到目前为止,我发现了什么。 如果cmd.exe以SYSTEM身份运行,则该应用程序会出现“拒绝访问”错误,但是在用户模式下它可以工作。
如何在系统模式下使用WMI? 我做错了什么?
ConnectionOptions options = new ConnectionOptions
{
Impersonation = ImpersonationLevel.Impersonate,
Authentication = AuthenticationLevel.PacketIntegrity,
EnablePrivileges = true,
SecurePassword = the_secure_password_of_remote_computer,
Username = the_username_of_remote_computer
};
var scope = new ManagementScope(@"\\" + the_ip_address_of_remote_computer +
@"\root\cimv2", options);
try
{
scope.Connect();
if (scope.IsConnected)
{
return true;
}
else
{
false;
}
} catch(Exception exception)
{
// I got the exception here.
Console.WriteLine("Exception|{0}", exception.Message);
return false;
}
我用编组来解决这个问题。
此处: http : //rzander.azurewebsites.net/create-a-process-as-loggedon-user/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.