国产探花免费观看_亚洲丰满少妇自慰呻吟_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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 屏东县| 巫山县| 延庆县| 凤冈县| 普兰店市| 霸州市| 昌图县| 南投县| 苗栗县| 金平| 安徽省| 马龙县| 孟连| 孝义市| 林甸县| 砀山县| 安达市| 石家庄市| 霞浦县| 友谊县| 明星| 成武县| 新竹县| 都安| 孟连| 南城县| 青铜峡市| 寿光市| 永靖县| 虹口区| 扶沟县| 宣威市| 扶风县| 定边县| 梧州市| 高青县| 修文县| 紫云| 乡宁县| 大埔县| 吐鲁番市|