网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 用VBS设置静态IP和DNS服务器地址的代码
范文
    用VBS设置静态IP和DNS服务器地址的代码,今天别人问我的,怕以后忘记,记录下来。
    代码如下:
    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
    记得把参数改成自己想要的。
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/25 1:28:24