zoukankan      html  css  js  c++  java
  • 用脚本实现“修复连接”的功能

    在编程时发现“ipconfig /renew”这条命令不等价于XP/2003在网卡状态查看中提供的“修复”(Repair)按钮,renew或release参数只对DHCP获得的 IP有效。而要真正实现修复连接的功能,还需要其它的步骤。上网搜索发现有人写了个bat文件,能实现类似修复连接的功能:
    @echo off
    ::
    :: IPREPAIR.CMD - Attempt to repair the network connections
    ::
    :: Written 12/16/03 by Rick Campbell
    ::

    :: Determine what OS this script is running on.
    if not "%OS%"=="Windows_NT" goto :end
    ver | find "[Version 5" || goto :end

    :: Clear environment variables
    set dhcp=

    :: Determine if client is dynamically or statically assigned an IP address
    echo Determining if client is DHCP based...
    for /f "tokens=3 delims= " %%d in (
    'netsh int ip sh add ^| find /i "DHCP"'
    ) do (
    set dhcp=%%d
    )

    :: If client is dynamic, then release and renew the IP address
    if /i "%dhcp%"=="Yes" (
    echo Client is using DHCP - Renewing the DHCP Address lease...
    ipconfig /release > nul
    ipconfig /renew > nul
    ) else (
    echo Client is statically assigned - leaving address untouched...
    )

    :: Flush the ARP, NetBIOS, and DNS cache's
    echo Flushing the ARP Cache...
    arp -d * > nul
    echo Flushing the NetBIOS Cache...
    nbtstat -R > nul
    echo Flushing the DNS Cache...
    ipconfig /flushdns > nul

    :: Re-register the NetBIOS and Computer names with WINS and DNS
    echo Re-registering the NetBIOS and Computer name with WINS and DNS...
    nbtstat -RR > nul
    ipconfig /registerdns > nul

    goto :eof

    :END
    echo This script is to be run on Windows 2000/XP/2003 Only!

    经实验,其实也并不完全等同于修复连接的功能,但我们可以通过这个批处理文件大致知道Windows修复连接时做了哪些事件。
  • 相关阅读:
    java 反射
    java 泛型实现原理
    java 常量池
    java String的intern()方法
    HashMap和Hashtable的区别
    Java反射
    初始JSP
    JSP动态网页
    关于学习Vue的前置工作/技术储备
    Java 高级开发必修知识---反射
  • 原文地址:https://www.cnblogs.com/wonderow/p/175841.html
Copyright © 2011-2022 走看看