ASP gets the network attribute configuration of the machine

Source: Internet
Author: User
The network is actually read the registry, but if you can get the IP configuration of the machine and other information, later configure IIS is simple.
The following script reads out all available IP addresses, subnet masks, but provincial gateways for the machine:

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 (a) & Chr (13)
& "IPAddress:" & IPAddress & Chr (a) & Chr (+) & "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 (a) & Chr (13)
& "IPAddress:" & IPAddress (i) & Chr (a) & Chr (+) & "SubnetMask:"
& SubnetMask (i))
Next
End If
End If

Description: The network configuration of the machine is stored in the registration table, under the network card items, so first must know the name of the network card. Then take the registry data, the IP address, and the child
The netmask is in the form of an array (in fact, the registry holds binary data, and VBScript helps us to convert it). Reading the registry in WSH is very simple, specific
Please look at the above procedure.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.