如何获取机器的网络配置属性?

来源:asp之家 时间:2009-11-23 20:44:00 

asp使用WScript.Shell获取电脑的网络配置信息

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("HKLM\SOFTWARE\Microsoft\Windows NT
CurrentVersion\NetworkCards\1\ServiceName") 
If sTcpipRegKey <> "Microsoft" And Err.Number = 0 Then 
sTcpipRegKey = "HKLM\SYSTEM\CurrentControlSet\Services\" 
& sNic & "\Parameters\Tcpip\" 
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) 
& "IPAddress: " & IPAddress(i) & Chr(10) & Chr(13) & "SubnetMask: " 
& SubnetMask(i)) 
Next 
End If 
End If 

标签:机器,配置,WScript.Shell
0
投稿

猜你喜欢

  • Zend Framework生成验证码并实现验证码验证功能(附demo源码下载)

    2024-05-03 15:13:30
  • 基于Bootstrap使用jQuery实现简单可编辑表格

    2023-08-22 20:15:07
  • python多进程中的内存复制(实例讲解)

    2022-01-20 23:34:46
  • Python利用逻辑回归分类实现模板

    2023-11-14 07:02:05
  • Python使用正则表达式抓取网页图片的方法示例

    2022-11-29 04:11:35
  • 一文看懂JSONP原理和应用

    2024-04-23 09:10:47
  • 浅谈Pandas 排序之后索引的问题

    2022-03-18 12:28:32
  • 详解Django3中直接添加Websockets方式

    2021-01-05 01:43:22
  • 404页面设计一样可以闪光

    2007-08-19 15:09:00
  • Spring + mybatis + mysql使用事物的几种方法总结

    2024-01-22 02:01:25
  • 生成二维码方法汇总

    2024-04-27 15:23:32
  • python3学习笔记之多进程分布式小例子

    2022-08-23 04:46:07
  • pandas数据聚合与分组运算的实现

    2021-09-18 18:29:12
  • meta标签之详解

    2008-01-13 18:48:00
  • Python中利用pyqt5制作指针钟表显示实时时间(指针时钟)

    2023-04-30 22:11:13
  • c#中过滤html的正则表达式

    2023-07-04 04:03:24
  • windows下Virtualenvwrapper安装教程

    2023-11-08 02:15:20
  • sqlserver 动态创建临时表的语句分享

    2024-01-17 23:57:45
  • Python ldap实现登录实例代码

    2021-03-12 21:38:55
  • Python中隐藏的五种实用技巧分享

    2023-08-23 15:12:05
  • asp之家 网络编程 m.aspxhome.com