Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I want a script or even a file to run, in a way that it changes ip when I run it.
Posted
Updated 11-May-11 8:33am
v2
Comments
Sandeep Mewara 11-May-11 13:47pm    
Elaborate on why and the complete scenario. It would help. (Update your question.)

The WMI way: Configuring TCP/IP Settings using WMI and C#[^].

Using netsh: http://www.csharptutors.com/?p=22[^]. This link may be useful for calling the command line:
http://stackoverflow.com/questions/206323/how-to-execute-command-line-in-c-get-std-out-results[^]

Note: Changing the IP address may have security restrictions.
 
Share this answer
 
v2
Comments
Kim Togo 12-May-11 5:09am    
My 5 for WMI.
Why? and what have you tried? A simple batch file using the ipconfig and it's associated switches would do the trick. You will need to expand your question for us to understand better what you are trying to accomplish.
 
Share this answer
 
Comments
Rick Shaub 11-May-11 14:39pm    
Ipconfig can't be used to change the IP address.
fjdiewornncalwe 11-May-11 14:43pm    
I realize he wants something else, but I'm trying to get him to provide more information in his question.
Rick Shaub 11-May-11 14:49pm    
He wants to change the IP address. Seems pretty self-explanatory to me.
If your IP is assigned dynamically, you could run the following utility with the specified commandline via a Process object:

ipconfig.exe /renew

If you DON'T have a dynamic IP, you have to use one of the other methods already described.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900