用于批处理。
通常我们都需要先 ipconfig /all >ipconfig.txt 
然后根据从ipconfig.txt里面找出连接名称例如("本地连接"或"本地连接 2")
仅仅使用批处理是很难做到的,于是我写个小exe程序(含PureBasic源代码)来完成此任务。
最后取出连接名称后就可以根据此名称来设置IP地址等东西:
netsh interface ip set address name="%ConnName%" source=static addr=%IPAddress% mask=%mask% gateway=%gway% gwmetric=1

其实,如果是XP可以通过WMIC来完成此任务。这个程序仅仅补充在 Windows 2000 Professional 下没有WMIC而做的。

PureBasic v4.02 源代码:
[quote]
OpenConsole()
n=0
txt$=ProgramParameter()
mac$=ProgramParameter()
If ReadFile(0, txt$)
  While Eof(0) = 0
    l$=ReadString(0)
    If Left(l$,16)="Ethernet adapter"
      nls$ = Mid(l$,18,Len(l$)-18)
      n=1
    EndIf
    
    If Left(l$,38)="   Physical Address. . . . . . . . . :" And n=1
      mls$ = Right(l$,17)
      If UCase(mls$)=UCase(mac$)
        PrintN(nls$)
      EndIf
      n=0
    EndIf
    
  Wend
  CloseFile(0)
EndIf
CloseConsole()
[/quote]

ipconfig /all >ipconfig.txt 的内容:
[quote]


Windows IP Configuration



   Host Name . . . . . . . . . . . . : LXASP

   Primary Dns Suffix  . . . . . . . : 

   Node Type . . . . . . . . . . . . : Unknown

   IP Routing Enabled. . . . . . . . : No

   WINS Proxy Enabled. . . . . . . . : No



Ethernet adapter 本地连接:



   Connection-specific DNS Suffix  . : 

   Description . . . . . . . . . . . : Realtek RTL8139 Family PCI Fast Ethernet NIC

   Physical Address. . . . . . . . . : 00-03-FF-93-39-9F

   DHCP Enabled. . . . . . . . . . . : No

   IP Address. . . . . . . . . . . . : 192.168.0.10

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   Default Gateway . . . . . . . . . : 192.168.0.1



PPP adapter 宽带连接:



   Connection-specific DNS Suffix  . : 

   Description . . . . . . . . . . . : WAN (PPP/SLIP) Interface

   Physical Address. . . . . . . . . : 00-53-45-00-00-00

   DHCP Enabled. . . . . . . . . . . : No

   IP Address. . . . . . . . . . . . : 219.128.234.90

   Subnet Mask . . . . . . . . . . . : 255.255.255.255

   Default Gateway . . . . . . . . . : 219.128.234.90

   DNS Servers . . . . . . . . . . . : 202.96.128.86

                                       202.96.128.166

   NetBIOS over Tcpip. . . . . . . . : Disabled


[/quote]