Using VBScript to get back the Network Card's Location

I need to identify the slot and port number of a NIC within a machine, this is because the machines in question have 8-10 NIC's depending on the machines requirements. I want to automate the renaming and static IP allocation on each adapter in a machine from an excel sheet/database without using the MAC.
Any help appreciated.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I do not think that this info is available easily, but check the program calle PCIinfo or similar ( DOS I think ) as it may be helpful


for more info

I hope this helps !
colinmussettTAAuthor Commented:

I have been searching the registry and found the reference in the registry here:


The value reads:

@system32\\drivers\\pci.sys,#65536;PCI bus %1, device %2, function %3;(3,0,0)

the numbers in the brackets being what im interested in, but need to be able to link this back to the network interface card, the above being just one of the NIC's and I have 8 in the machine.

Help appreciated.
colinmussettTAAuthor Commented:

i have attached an image with the informatin im trying to retreive, can anyone help with this ?
Paste the script below into a text file with a .vbs extension.  Running it will echo the name and location of each hardware NIC in the machine.

If you'd like it to read directly from an Excel sheet please provide an example and more detail about how you'd like it to work.

Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005
On Error Resume Next
Set objShell=CreateObject("WScript.Shell")
Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv")
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter")
For Each objItem In colItems
    strName = objItem.Name
    strID = objItem.PNPDeviceID
    strKey = "SYSTEM\CurrentControlSet\Enum\" & strID
    objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey, "LocationInformation", strLoc
    If strLoc Then
        WScript.Echo strName & " - " & strLoc
    End If

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
colinmussettTAAuthor Commented:
thanks for that, worked perfectly and helped me along considrably.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Networking Hardware-Other

From novice to tech pro — start learning today.