用vbs實(shí)現(xiàn)配置靜態(tài) IP 地址
更新時(shí)間:2007年05月14日 00:00:00 作者:
將計(jì)算機(jī)的 IP 地址設(shè)置為 192.168.1.141,并將 IP 網(wǎng)關(guān)設(shè)置為 192.168.1.100。
腳本代碼
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array("192.168.1.141")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.100")
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 address has been changed."
Else
WScript.Echo "The IP address could not be changed."
End If
Next
腳本代碼
復(fù)制代碼 代碼如下:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array("192.168.1.141")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.100")
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 address has been changed."
Else
WScript.Echo "The IP address could not be changed."
End If
Next
相關(guān)文章
VBS教程:方法-GetAbsolutePathName 方法
VBS教程:方法-GetAbsolutePathName 方法...2006-11-11VBS教程:函數(shù)-InputBox 函數(shù)
VBS教程:函數(shù)-InputBox 函數(shù)...2006-11-11注冊(cè)表-批處理-VBS之間的功能對(duì)應(yīng)
這篇文章主要介紹了注冊(cè)表-批處理-VBS之間的功能對(duì)應(yīng)2007-02-02VBS基礎(chǔ)篇 - VBScript過程(使用sub 與 Function定義函數(shù))
在 VBScript 中,過程被分為兩類:Sub 過程和 Function 過程,需要的朋友可以參考下2018-05-05遠(yuǎn)程或本地獲取系統(tǒng)信息的腳本RGIS.vbs
遠(yuǎn)程或本地獲取系統(tǒng)信息的腳本RGIS.vbs...2007-02-02Restart.vbs源代碼可以重啟遠(yuǎn)程電腦的vbs
Restart.vbs源代碼可以重啟遠(yuǎn)程電腦的vbs...2007-02-02vbs打開ie兩種方法 在VBScript中啟動(dòng)IE瀏覽器的實(shí)現(xiàn)代碼
用VBS打開網(wǎng)頁(yè),減少IE廣告, 不錯(cuò)的東東,是在網(wǎng)上收集的,你也可以實(shí)現(xiàn)網(wǎng)頁(yè)的自動(dòng)登錄等2013-01-01