blazerguns
September 20th, 2006, 07:28 AM
Hi all,
Iam new to using wmi methods. I tried to enable wins using wmi. The code is below.
public void EnableWinsServer()
{
ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection objMOC = objMC.GetInstances();
foreach (ManagementObject objMO in objMOC)
{
if (!(bool)objMO["IPEnabled"])
continue;
ManagementBaseObject NewobjWins = null;
ManagementBaseObject SetobjWins = null;
NewobjWins = objMO.GetMethodParameters("EnableWINS");
NewobjWins["DNSEnabledForWINSResolution"] = (bool)false;
NewobjWins["WINSEnableLMHostsLookup"] = (bool)true;
SetobjWins = objMO.InvokeMethod("EnableWINS", NewobjWins, null);
}
}
Iam getting an exception on InvokeMethod("EnableWINS"....).
It says "Invalid Method". may be iam wrong but can someone correct me how to go about it.
Its urgent.
Another doubt is how can i use wmi method to find out if the dns server ips are got from dhcp or from user manual entry?
Varun
Iam new to using wmi methods. I tried to enable wins using wmi. The code is below.
public void EnableWinsServer()
{
ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection objMOC = objMC.GetInstances();
foreach (ManagementObject objMO in objMOC)
{
if (!(bool)objMO["IPEnabled"])
continue;
ManagementBaseObject NewobjWins = null;
ManagementBaseObject SetobjWins = null;
NewobjWins = objMO.GetMethodParameters("EnableWINS");
NewobjWins["DNSEnabledForWINSResolution"] = (bool)false;
NewobjWins["WINSEnableLMHostsLookup"] = (bool)true;
SetobjWins = objMO.InvokeMethod("EnableWINS", NewobjWins, null);
}
}
Iam getting an exception on InvokeMethod("EnableWINS"....).
It says "Invalid Method". may be iam wrong but can someone correct me how to go about it.
Its urgent.
Another doubt is how can i use wmi method to find out if the dns server ips are got from dhcp or from user manual entry?
Varun