使用Script設定ip相關設定

使用Script設定ip相關設定

文章kaku » 2012年 1月 10日, 13:26

設定DNS
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
arrPrimaryServer = array("10.1.1.214")
strDNSDomain = "citfund.com.tw"
objNetCard.SetDNSServerSearchOrder(arrPrimaryServer)
objNetCard.SetDNSDomain strDNSDomain
Next

設定Default Gateway
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
arrGateway = array("10.1.1.254")
objNetCard.SetGateways(arrGateway)
Next

設定IP Address
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
arrIPAddress = array("10.1.1.147")
arrSubnetMask = array("255.255.255.0")
objNetCard.EnableStatic arrIPAddress, arrSubnetMask
Next

設定Wins
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
strPrimaryServer = "10.1.1.214"
strSecondaryServer = ""
objNetCard.SetWINSServer strPrimaryServer, strSecondaryServer
Next
Kaku Liao 網路系統工程師
明泓科技顧問股份有限公司
RACE Computer Information Corp.
http://www.race.com.tw
頭像
kaku
系統管理員
 
文章: 193
註冊時間: 2011年 8月 25日, 14:09
來自: Taiwan

回到 Windows XP/Vista/7/8/8.1/10 討論區

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客

cron