473,399 Members | 3,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Dynamically change IP Address

DMA
How can I change my IP address ?
I try to do it in C#.
It's easy to get the IP but to fix it is another problem..

Thanks.

Sep 8 '06 #1
4 4633
WMI as usual :)
http://www.dotnet247.com/247referenc...20/104068.aspx

--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


"DMA" wrote:
How can I change my IP address ?
I try to do it in C#.
It's easy to get the IP but to fix it is another problem..

Thanks.

Sep 8 '06 #2
WMI as usual :)
http://www.dotnet247.com/247referenc...20/104068.aspx
As I recall WMI isn't active by default on Windows Server 2003 (needs to be
turned on via "Add/Remove Windows Components" under "Add/Remove" programs in
the Control Panel). Those targetting this platform then have a problem
(forcing customers to activate this feature which they may not want to do).
Sep 8 '06 #3
DMA
I have found something about that and actually I am trying to get it
work.
Thank you.
I will see on monday.
I just had to add a reference to System.Management that is not by
default in C# Express.
Michael Nemtsev wrote:
WMI as usual :)
http://www.dotnet247.com/247referenc...20/104068.aspx

--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


"DMA" wrote:
How can I change my IP address ?
I try to do it in C#.
It's easy to get the IP but to fix it is another problem..

Thanks.
Sep 8 '06 #4
DMA
That code works very well ! :
ManagementBaseObject inPar = null;
ManagementBaseObject outPar = null;
ManagementClass mc = new
ManagementClass("Win32_NetworkAdapterConfiguration ");
ManagementObjectCollection moc = mc.GetInstances();
try
{
foreach (ManagementObject mo in moc)
{
if (!(bool)mo["IPEnabled"])
continue;

inPar = mo.GetMethodParameters("EnableStatic");
inPar["IPAddress"] = new string[] {
"10.59.245.186" };
inPar["SubnetMask"] = new string[] {
"255.255.0.0" };
outPar = mo.InvokeMethod("EnableStatic", inPar,
null);
MonIP.Text = "10.59.245.186";
}
}
catch (Exception ex)
{
MessageBox.Show("Problème au changement d'IP (" +
ex.Message + ")", "erreur", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}

Sep 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dave Nouwens | last post by:
Hi All, Please accept my appologies in advance for what I expect will be a reasonably simple question. I have an html form (which is generated in php) which contains a number of rows (one row...
5
by: Angel | last post by:
Is there a way to create an IFRAME dynamically via VB.NET. In other words creating the HTML element in the server side code? thanks in advance....
27
by: ted benedict | last post by:
hi everybody, i hope this is the right place to discuss this weird behaviour. i am getting dynamically generated text or xml from the server side using xmlhttprequest. if the server side data is...
94
by: smnoff | last post by:
I have searched the internet for malloc and dynamic malloc; however, I still don't know or readily see what is general way to allocate memory to char * variable that I want to assign the substring...
36
by: Martin Larsen | last post by:
Hi, When a PHP program links to a library using include or require (or their _once variations), is the library then linked dynamically or statically? While it might seem irrelevant from a...
1
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and...
1
by: John Dow | last post by:
I have an ASP.Net project, in which I added a web reference, for example http://Sandbox/service.asmx after I pass the testing, I want to change the web service address to...
2
by: ssmith147 | last post by:
Hi, I'm somewhat familiar with access and vb programming (I can read someone else's code, for the most part), but I'm still very green when it comes to creating solutions for my own needs. I'm...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
1
by: nsteiner | last post by:
Hi all On my web page I have a 3 column table. The first cell changes background color when mouseover event occurs. Something like this : <TR><TD onMouseOver="this.bgColor='#00CC00'"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
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...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.