ASP gets the network attribute configuration of the machine

Source: Internet
Author: User
In fact, it is to 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 ("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 (a) & Chr (13)


& "IPAddress:" & IPAddress & Chr (a) & Chr (a) & "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 (a) & "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 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.