时间:2021-05-22
用以返回配置数据(类似于IPCONFIG命令返回信息)的WMI脚本。
'ReturningIPConfigurationData
'WMIscriptthatreturnsconfigurationdatasimilartothatreturnedbyIpConfig.
strComputer="."
SetobjWMIService=GetObject("winmgmts:\\"&strComputer&"\root\cimv2")
SetcolAdapters=objWMIService.ExecQuery_
("SELECT*FROMWin32_NetworkAdapterConfigurationWHEREIPEnabled=True")
n=1
WScript.Echo
ForEachobjAdapterincolAdapters
WScript.Echo"NetworkAdapter"&n
WScript.Echo"================="
WScript.Echo"Description:"&objAdapter.Description
WScript.Echo"Physical(MAC)address:"&objAdapter.MACAddress
WScript.Echo"Hostname:"&objAdapter.DNSHostName
IfNotIsNull(objAdapter.IPAddress)Then
Fori=0ToUBound(objAdapter.IPAddress)
WScript.Echo"IPaddress:"&objAdapter.IPAddress(i)
Next
EndIf
IfNotIsNull(objAdapter.IPSubnet)Then
Fori=0ToUBound(objAdapter.IPSubnet)
WScript.Echo"Subnet:"&objAdapter.IPSubnet(i)
Next
EndIf
IfNotIsNull(objAdapter.DefaultIPGateway)Then
Fori=0ToUBound(objAdapter.DefaultIPGateway)
WScript.Echo"Defaultgateway:"&objAdapter.DefaultIPGateway(i)
Next
EndIf
WScript.Echo
WScript.Echo"DNS"
WScript.Echo"---"
WScript.Echo"DNSserversinsearchorder:"
IfNotIsNull(objAdapter.DNSServerSearchOrder)Then
Fori=0ToUBound(objAdapter.DNSServerSearchOrder)
WScript.Echo""&objAdapter.DNSServerSearchOrder(i)
Next
EndIf
WScript.Echo"DNSdomain:"&objAdapter.DNSDomain
IfNotIsNull(objAdapter.DNSDomainSuffixSearchOrder)Then
Fori=0ToUBound(objAdapter.DNSDomainSuffixSearchOrder)
WScript.Echo"DNSsuffixsearchlist:"&objAdapter.DNSDomainSuffixSearchOrder(i)
Next
EndIf
WScript.Echo
WScript.Echo"DHCP"
WScript.Echo"----"
WScript.Echo"DHCPenabled:"&objAdapter.DHCPEnabled
WScript.Echo"DHCPserver:"&objAdapter.DHCPServer
IfNotIsNull(objAdapter.DHCPLeaseObtained)Then
utcLeaseObtained=objAdapter.DHCPLeaseObtained
strLeaseObtained=WMIDateStringToDate(utcLeaseObtained)
Else
strLeaseObtained=""
EndIf
WScript.Echo"DHCPleaseobtained:"&strLeaseObtained
IfNotIsNull(objAdapter.DHCPLeaseExpires)Then
utcLeaseExpires=objAdapter.DHCPLeaseExpires
strLeaseExpires=WMIDateStringToDate(utcLeaseExpires)
Else
strLeaseExpires=""
EndIf
WScript.Echo"DHCPleaseexpires:"&strLeaseExpires
WScript.Echo
WScript.Echo"WINS"
WScript.Echo"----"
WScript.Echo"PrimaryWINSserver:"&objAdapter.WINSPrimaryServer
WScript.Echo"SecondaryWINSserver:"&objAdapter.WINSSecondaryServer
WScript.Echo
n=n+1
Next
FunctionWMIDateStringToDate(utcDate)
WMIDateStringToDate=CDate(Mid(utcDate,5,2)&"/"&_
Mid(utcDate,7,2)&"/"&_
Left(utcDate,4)&""&_
Mid(utcDate,9,2)&":"&_
Mid(utcDate,11,2)&":"&_
Mid(utcDate,13,2))
EndFunction
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
描述信息用以返回配置数据(类似于IPCONFIG命令返回信息)的WMI脚本。脚本代码复制代码代码如下:'ReturningIPConfigurationData
描述返回安装在计算机中的每个支持IP的网络适配器的IP地址。脚本代码复制代码代码如下:strComputer="."SetobjWMIService=GetOb
用这个脚本管理之前,需要先配置下面的内核参数,否则Redis脚本在重启或停止redis时,将会报错,并且不能自动在停止服务前同步数据到磁盘上:复制代码代码如下:
错误描述:当执行用VBScript写的WScript脚本时,出现了下面的错误:Thereisnoscriptengineforfileextension".vb
在使用VBScript时,我们可以用Application缓存数组来实现缓存,例:程序代码:复制代码代码如下:Dimrs,arrrs.Openconn,sql,