脚本 VBS 配置 IP
由于工作需要,经常需要切换IP地址,以前有两张网卡,现在只有一张了,经常改的时候报告 www.shengfang.org
您为这个网络适配器输入的 IP 地址 192 .168 .3 .137 已经分配给另一个适配器 'AMD PCNET Family PCI
Ethernet Adapter' 。 'AMD PCNET Family PCI Ethernet Adapter' 从网络文件夹中隐藏 , 因为它本身并没
有在计算机中存在 , 或是个不工作的旧适配器 。 如果相同的地址分配给两个适配器 , 并且它们都处于活动状
态 , 只有一个会使用这个地址 。 这会造成不正确的系统配置 。
5 %
您想从高级对话框的 IP 地址列表输入不同的 IP 地址给这个适配器吗 ?
非常讨厌,所以上网到MSDN找了个VBS www.shengfang.org
TechNet 主页 > 脚本中心 > 脚本分类 > 网络
http://www.microsoft.com/china/technet/community/scriptcenter/network/scrnet01.mspx
配置静态 IP 地址 更新日期: 2003年02月17日
描述 www.shengfang.org
c:\>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : sf
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Unknown
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter MAC:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Macronix MX98715-Based Ethernet Adap
ter (Generic)
Physical Address. . . . . . . . . : 00-D0-F8-00-55-F9
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 192.168.12.235
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IP Address. . . . . . . . . . . . : 192.168.3.137
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.3.1
DNS Servers . . . . . . . . . . . : 1.2.3.4
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array("192.168.3.137","192.168.12.235")
strSubnetMask = Array("255.255.255.0","255.255.255.0")
strGateway = Array("192.168.3.1")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
If errEnable = 0 Then
WScript.Echo "The IP 192.168.3.137 address has been changed."
Else
WScript.Echo "The IP 192.168.3.137 address could not be changed."
End If
Next
For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.
免责声明 www.shengfang.org
以上示例脚本不会获得由任何Microsoft标准支持计划或服务项目所提供的支持。这些示例脚本在提交时并未附带任何形式的保证承诺。不仅如此,Microsoft公司还不加限定条件地针对所有默许保证责任加以进一步否认,这其中便包括出于特定目的而针对适销性或适用性所承担的默许保证责任。因使用或执行上述示例脚本及文档资料而导致的全部风险均由读者自行承担。在任何情况下,Microsoft公司及其创作人员、亦或与上述脚本的创意、编制及提交有关的任何人员均无须针对因使用或无法使用上述示例脚本或文档资料所导致的任何损害(其中包括,企业利润损失、经营中断、业务信息丢失及其它经济损失)承担责任;即使Microsoft公司已被告知造成这种损害可能性,上述免责条款依然适用。
搞定,也没有那个提示了,不过看看这个 免责声明 ,真是够厉害的! 应该算霸王条款了。
另外脚本中心还 Scripting Languages Available in the Script Center www.shengfang.org
http://www.microsoft.com/technet/scriptcenter/scripts/language.mspx
• Perl Sample scripts written in Perl, a scripting language delivered by ActiveState for use on Linux, Solaris and Windows platforms.
• Python Sample scripts written in Python, a scripting language delivered by ActiveState for use on Linux, Solaris and Windows platforms.
• JScript Sample scripts written in JScript, Microsoft’s implementation of the ECMA 262 language specification (ECMAScript Edition 3).
• VBScript Sample scripts written in Microsoft’s VBScript, the language most commonly used when writing scripts that perform system administration tasks.
• Kixtart Sample scripts written in Kixtart, a logon script processor and enhanced batch scripting language for computers running Windows XP, Windows 2000, Windows NT or Windows 9x.
• Object REXX Sample scripts written in IBM’s Object REXX, a language that provides open interfaces to many system functions and to other applications, such as IBM's DB2 for relational databases, TCP/IP sockets for communications, and C for programming.
PERL PYTHON JSCRIPT VBSCRIPT还听过,后面两个就比较冷门了。 www.shengfang.org