[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[网络连接] [已解决]批处理怎样自动填写静态IP地址?

192.168.0.11
255.255.255.0
192.168.0.1

202.106.0.20
1

评分人数

    • zm900612: 感谢给帖子标题标注[已解决]字样PB + 2

netsh!
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

  1. netsh interface ip set address 本地连接 static 192.168.0.11 255.255.255.0 192.168.0.1 1
  2. netsh interface ip set dns name="本地连接" source=static addr=202.106.0.20
复制代码
1

评分人数

TOP

  1. echo off
  2. cls
  3. echo 如果您的电脑不是通过小区路由上网或家里未安装路由器的请不要使用本软件!
  4. pause>nul
  5. :1
  6. cls
  7. echo 1 快速设为192.168.1.100
  8. echo 2 自定义设置IP和路由
  9. echo 3 清除所有IP设置
  10. echo 4 退出
  11. for /l %%1 in (1,1,3) do echo.
  12. set /p p= 请选择:
  13. if %p%==1 goto :快速设置
  14. if %p%==2 goto :ipsz
  15. if %p%==3 goto :清除
  16. if %p%==4 goto :eof
  17. goto :1
  18. :ipsz
  19. cls
  20. echo  --------------------------------------------------------------------------
  21. echo           填入IP,注意格式...
  22. echo.
  23. set/p ip=  你要设置的IP:
  24. echo.
  25. echo           掩码不用填,默认为255.255.255.0
  26. echo.
  27. echo           填入网关,注意格式...
  28. echo.
  29. set/p wg=  你要设置的网关:
  30. echo.
  31. echo  --------------------------------------------------------------------------
  32. echo.
  33. echo           填入主DNS
  34. echo.
  35. set/p dns1=  主DNS:
  36. echo.
  37. echo           填入备用DNS
  38. echo.
  39. set/p dns2=  备用DNS:
  40. echo.
  41. echo  --------------------------------------------------------------------------
  42. echo.
  43. echo           填入计算机名
  44. echo.
  45. set/p computername=   计算机名:
  46. echo.
  47. echo           填入工作组
  48. echo.
  49. set/p newwg=   工作组:
  50. :tw
  51. cls
  52. echo  本机ip为       %ip%
  53. echo  本机网关为     %wg%
  54. echo  DNS为          %dns1%         %dns2%
  55. echo  计算机名为     %computername%
  56. echo  工作组为       %newwg%
  57. echo.
  58. echo  以上信息是否正确?
  59. echo        1、正确开始写入
  60. echo        2、不正确我要重填
  61. echo        3、退出
  62. echo.
  63. set/p pp=  您的选择:
  64. if %pp%==1 goto trip
  65. if %pp%==2 goto ipsz
  66. if %pp%==3 goto end
  67. goto tw
  68. :trip
  69. echo 正在更改计算机名请稍后...... 改名为:%computername%
  70. reg add HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName /v ComputerName /t REG_SZ /d %computername% /f > nul
  71. reg add HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName /t REG_SZ /d %computername% /f > nul
  72. reg add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v Hostname /t REG_SZ /d %computername% /f > nul
  73. reg add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v "NV Hostname" /t REG_SZ /d %computername% /f > nul
  74. echo      正在设置IP及子网掩码 IP为 %ip%  掩码为 255.255.255.0
  75. netsh interface ip set address name="本地连接" source=static addr=%ip%  mask=255.255.255.0
  76. echo      正在设置网关地址 网关为:%wg%
  77. netsh interface ip set address name="本地连接" gateway=%wg% gwmetric=0
复制代码
1

评分人数

世界上没有学不会的知识,也没有想得到却做不到的事!

TOP

本帖最后由 xlybzk 于 2011-6-7 12:37 编辑

楼上的不用那么麻烦
  1. netsh interface ip set address 本地连接 static 192.168.0.11 255.255.255.0 192.168.0.1 1 & netsh interface ip set dns 本地连接 static 202.106.0.20
复制代码
1

评分人数

TOP

返回列表