国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > VBScript > 正文

用VBS設置靜態IP和DNS服務器地址的代碼

2020-07-26 11:51:43
字體:
來源:轉載
供稿:網友

核心代碼一:

strIPAddress = Array("192.168.0.148") strSubnetMask = Array("255.255.255.0") strGateway = Array("192.168.0.1") strGatewayMetric = Array(1) arrDNSServers = Array("192.168.0.1","192.168.0.2") strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2") Set colNetAdapters = objWMIService.ExecQuery _ ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") For Each objNetAdapter in colNetAdapters errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask) errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric) errDNS = objNetAdapter.SetDNSServerSearchOrder(arrDNSServers) 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 

記得把參數改成自己想要的。

代碼二:

將計算機的 IP 地址設置為 192.168.1.111,并將 IP 網關設置為 192.168.1.1。

strComputer = "." Set objWMIService = GetObject("winmgmts:/" & strComputer & " ootcimv2") Set colNetAdapters = objWMIService.ExecQuery _ ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") strIPAddress = Array("192.168.1.111") strSubnetMask = Array("255.255.255.0") strGateway = Array("192.168.1.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 address has been changed." Else WScript.Echo "The IP address could not be changed." End If Next

原文:http://demon.tw/programming/vbs-modify-ip-dns-setting.html

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 江陵县| 东城区| 巴马| 江安县| 甘孜县| 乌恰县| 满城县| 廉江市| 邵武市| 乐昌市| 霍邱县| 长乐市| 天气| 抚州市| 云和县| 岫岩| 安化县| 宽城| 新蔡县| 宿松县| 泸州市| 吴桥县| 皋兰县| 加查县| 九江市| 渭南市| 郁南县| 志丹县| 鸡西市| 吴江市| 玉溪市| 敦煌市| 措美县| 临猗县| 綦江县| 赫章县| 虹口区| 阿鲁科尔沁旗| 萝北县| 金堂县| 宜阳县|