如何在c#中更改IP?或任何其他方式 [英] How do I change IP in c# ? or any other way

查看:121
本文介绍了如何在c#中更改IP?或任何其他方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望运行脚本甚至文件,以使其在运行时更改ip.

I want a script or even a file to run, in a way that it changes ip when I run it.

推荐答案

WMI方式:使用WMI和C#配置TCP/IP设置 [ http://www.csharptutors.com/?p=22 [ http://stackoverflow.com/questions/206323/how-to-execute-command-line-in-c-get-std-out-results [
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.


为什么?你尝试了什么?使用ipconfig及其关联的开关的简单批处理文件就可以解决问题.您将需要扩展您的问题,以便我们更好地理解您要完成的任务.
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.


如果您的IP是动态分配的,则可以通过Process对象:

ipconfig.exe /renew

如果您没有动态IP,则必须使用已经描述的其他方法之一.
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.


这篇关于如何在c#中更改IP?或任何其他方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆