最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
使用WSH读取注册表
时间:2022-06-30 09:48:05 编辑:袖梨 来源:一聚教程网
其实就是读注册表,不过如果能获得机器的IP配置等信息,以后配置IIS时就简单了。
下面的脚本读出机器的所有可用IP地址,子网掩码,却省网关等信息:
Option Explicit
Dim WSHShell
Dim sNic, sMan
Dim Gateway
Dim IPAddress
Dim SubnetMask
Dim i
Dim sTcpipRegKey
Dim bIsDHCP
Set WSHShell = CreateObject("WScript.Shell")
sNic = WSHShell.RegRead("HKLMSOFTWAREMicrosoftWindows NT
CurrentVersionNetworkCards1ServiceName")
If sTcpipRegKey <> "Microsoft" And Err.Number = 0 Then
sTcpipRegKey = "HKLMSYSTEMCurrentControlSetServices"
& sNic & "ParametersTcpip"
bIsDHCP = WSHShell.RegRead(sTcpipRegKey & "EnableDHCP")
If bIsDHCP Then
Gateway = WSHShell.RegRead(sTcpipRegKey & "DhcpDefaultGateway")
IPAddress = WSHShell.RegRead(sTcpipRegKey & "DhcpIPAddress")
SubnetMask = WSHShell.RegRead(sTcpipRegKey & "DhcpSubnetMask")
MsgBox ("DefaultGateway: " & Gateway(0) & Chr(10) & Chr(13)
& "IPAddress: " & IPAddress & Chr(10) & Chr(13) & "SubnetMask: " & SubnetMask)
Else
Gateway = WSHShell.RegRead(sTcpipRegKey & "DefaultGateway")
IPAddress = WSHShell.RegRead(sTcpipRegKey & "IPAddress")
SubnetMask = WSHShell.RegRead(sTcpipRegKey & "SubnetMask")
For i=0 to Ubound(IPAddress)-1
MsgBox ("DefaultGateway: " & Gateway(0) & Chr(10) & Chr(13)
下面的脚本读出机器的所有可用IP地址,子网掩码,却省网关等信息:
Option Explicit
Dim WSHShell
Dim sNic, sMan
Dim Gateway
Dim IPAddress
Dim SubnetMask
Dim i
Dim sTcpipRegKey
Dim bIsDHCP
Set WSHShell = CreateObject("WScript.Shell")
sNic = WSHShell.RegRead("HKLMSOFTWAREMicrosoftWindows NT
CurrentVersionNetworkCards1ServiceName")
If sTcpipRegKey <> "Microsoft" And Err.Number = 0 Then
sTcpipRegKey = "HKLMSYSTEMCurrentControlSetServices"
& sNic & "ParametersTcpip"
bIsDHCP = WSHShell.RegRead(sTcpipRegKey & "EnableDHCP")
If bIsDHCP Then
Gateway = WSHShell.RegRead(sTcpipRegKey & "DhcpDefaultGateway")
IPAddress = WSHShell.RegRead(sTcpipRegKey & "DhcpIPAddress")
SubnetMask = WSHShell.RegRead(sTcpipRegKey & "DhcpSubnetMask")
MsgBox ("DefaultGateway: " & Gateway(0) & Chr(10) & Chr(13)
& "IPAddress: " & IPAddress & Chr(10) & Chr(13) & "SubnetMask: " & SubnetMask)
Else
Gateway = WSHShell.RegRead(sTcpipRegKey & "DefaultGateway")
IPAddress = WSHShell.RegRead(sTcpipRegKey & "IPAddress")
SubnetMask = WSHShell.RegRead(sTcpipRegKey & "SubnetMask")
For i=0 to Ubound(IPAddress)-1
MsgBox ("DefaultGateway: " & Gateway(0) & Chr(10) & Chr(13)
相关文章
- 《夜族崛起》铁匠西里尔位置一览 05-17
- 《寓言之地》1.02更新内容一览 05-17
- 《辐射4》steam好评率介绍 05-17
- 《夜族崛起》技能强化珠宝掉落说明 05-17
- 《辐射4》主机控制台介绍 05-17
- 《星露谷物语》海草和绿藻获取方法 05-17