Board logo

标题: [网络连接] [已解决]批处理怎样自动填写静态IP地址? [打印本页]

作者: qq544935474    时间: 2011-6-6 17:40     标题: [已解决]批处理怎样自动填写静态IP地址?

192.168.0.11
255.255.255.0
192.168.0.1

202.106.0.20
作者: Batcher    时间: 2011-6-6 17:44

netsh!
作者: 601997526    时间: 2011-6-6 20:02

  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
复制代码

作者: mxxcgzxxx    时间: 2011-6-6 20:02

  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
复制代码

作者: xlybzk    时间: 2011-6-7 12:21

本帖最后由 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
复制代码





欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2