I'm createing a tool to managet ip addresses, this is a profile
manager. I can control ip and subnet, but i can't control dns and
wins. The error i get is "invalid method", the code im using is below
here. Can someone tell what im doing wrong?..
//create objects
ManagementBaseObject obj_ip = null;
ManagementBaseObject obj_gateway = null;
ManagementBaseObject obj_wins = null;
ManagementBaseObject obj_dns = null;
ManagementBaseObject obj_output = null;
// get method
obj_ip = management_object.GetMethodParameters("EnableStati c");
obj_gateway = management_object.GetMethodParameters("SetGateways ");
obj_dns = management_object.GetMethodParameters("EnableDNS") ;
obj_wins = management_object.GetMethodParameters("SetWINSServ er");
//Set DefaultGateway
obj_gateway["DefaultIPGateway"] = new string[] { gateway };
obj_gateway["GatewayCostMetric"] = new int[] { 1 };
//Set IPAddress and Subnet Mask
obj_ip["IPAddress"] = new string[] { ip_address };
obj_ip["SubnetMask"] = new string[] { subnet_mask };
// set wins server
obj_wins["WINSPrimaryServer"] = new string[] { wins };
//// set dns servers
obj_dns["DNSServerSearchOrder"] = new string[] { primary_dns,
secudary_dns };
obj_output = management_object.InvokeMethod("EnableStatic", obj_ip,
null);
obj_output = management_object.InvokeMethod("SetGateways",
obj_gateway, null);
obj_output = management_object.InvokeMethod("EnableDNS", obj_dns,
null);
obj_output = management_object.InvokeMethod("SetWINSServer", obj_wins,
null); 2 4370
hi ho!
i got the same problem with WINS, but i can change the DNS serves like this:
public void setDNS(string NIC, string DNS)
{
ManagementClass objMC = new
ManagementClass("Win32_NetworkAdapterConfiguration ");
ManagementObjectCollection objMOC = objMC.GetInstances();
foreach (ManagementObject objMO in objMOC)
{
if ((bool)objMO["ipEnabled"])
{
if (objMO["Caption"].Equals(NIC))
{
ManagementBaseObject newDNS =
objMO.GetMethodParameters("SetDNSServerSearchOrder ");
newDNS["DNSServerSearchOrder"] = DNS.Split(',');
ManagementBaseObject setDNS =
objMO.InvokeMethod("SetDNSServerSearchOrder", newDNS, null);
}
}
}
}
hi folks,
today i solve the problem to set the wins server using C# and WMI, i use the
following function to set primary and secondary WINS server... hope it's
useful for you!
greetz. nO_okY
public void setWINS(string NIC, string priWINS, string secWINS)
{
ManagementClass objMC = new
ManagementClass("Win32_NetworkAdapterConfiguration ");
ManagementObjectCollection objMOC = objMC.GetInstances();
foreach (ManagementObject objMO in objMOC)
{
if ((bool)objMO["ipEnabled"])
{
if (objMO["Caption"].Equals(NIC))
{
ManagementBaseObject setWINS;
ManagementBaseObject wins =
objMO.GetMethodParameters("SetWINSServer");
wins.SetPropertyValue("WINSPrimaryServer", priWINS);
wins.SetPropertyValue("WINSSecondaryServer", secWINS);
setWINS = objMO.InvokeMethod("SetWINSServer", wins,
null);
}
}
}
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bill Struve |
last post by:
Need: Auto-logon to a terminal server, start a program, and, when the user
is quits the program, auto-logoff.
Problem: When msrdp.ocx is added to the Toolbox, attempting to draw the
control on...
|
by: Anthony Nystrom |
last post by:
I need to within code control some printer settings before raising the print dialog... I need to set some properties for the printer such as "The Printer to Print too", Page settings such as paper...
|
by: Miguel |
last post by:
Hi,
I'm developing an application in C# with Windows Forms for my company
that is similar to the MSN Messenger. This application uses a
webservice for registering users, etc... and as 2...
|
by: pealy2 |
last post by:
Sorry if this is in the wrong group, I've searched long & hard without
finding anything even slightly useful. (recommendations for a more
relevant group gratefuly received)
I need to change the...
|
by: Pieter |
last post by:
Hi,
I've a activex browser control in a form. I've added proxy server
support to the control by modifying the proxy server settings in the
registry. This works fine before the browser control is...
|
by: GAZ |
last post by:
Hello all,
We have a bit of a problem with application settings and user control. In
short, we have developed a user control that should, as it happenes, get a
value stored in application...
|
by: Steve Long |
last post by:
Hello.
Can anyone tell me the proper way to save the properties of a user control
between design time and run time?
So, I've got this user control with the following properties:
BarColor1...
|
by: shapper |
last post by:
Hello,
I have a class where I created various controls.
One of the controls have a property which is a generic list of
WebControl.
Then in web site page I have something like:
Dim a As New...
|
by: =?Utf-8?B?R3JlZw==?= |
last post by:
I am used to using third party controls when it comes to setting up
appearences. But, now I am using Visual Basic.Net controls that come standard
with the product. I've come across a frustration...
|
by: Just_a_fan |
last post by:
I am adding a bunch of controls with the code below.
Problem 1: When program flow passes to "UpperChanged" when I click it,
the control name is undefined. When I enter:
If udUpperLim1.Value 1...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |