How to access LAN Computer with Local Administrator using Windows Management Instrumentation (WMI).


Access LAN Computer with Local Administrator using Windows Management Instrumentation (WMI).
Follow below setting for every LAN Computer you want to access.
Settings:

  • Go to Control Panel
  • Open Windows Firewall
  • Open Inbound Rules
  • Enable Windows Management Instrumentation (WMI-In)¬†for domain profile.

ManagementNamedValueCollection mContext = new ManagementNamedValueCollection();
mContext.Add("__ProviderArchitecture", 64);
mContext.Add("__RequiredArchitecture", false);
ConnectionOptions options = new ConnectionOptions();
ManagementScope ManagementScope1 = new ManagementScope();
bool isConnect = false;
try
{
options.Username = Local Administrator UserId;
options.Password = Local Administrator Password;
options.Authority = "ntlmdomain:DOMAIN";
options.Impersonation = ImpersonationLevel.Impersonate;
options.EnablePrivileges = true;
options.Context = mContext;

ManagementScope1 = new ManagementScope(string.Format("\\\\{0}\\root\\cimv2", "IP Address"), options);
ManagementScope1.Connect();
isConnect = true;
}
catch (Exception ex)
{
}