?
Solved

Using VBScript to get back the Network Card's Location

Posted on 2008-11-05
5
Medium Priority
?
939 Views
Last Modified: 2013-11-09
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.
0
Comment
Question by:colinmussett
  • 3
5 Comments
 
LVL 63

Expert Comment

by:SysExpert
ID: 22890387
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

see

http://members.datafast.net.au/dft0802/other.htm

for more info


I hope this helps !
0
 

Author Comment

by:colinmussett
ID: 22893310

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

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI\VEN_14E4&DEV_170C&SUBSYS_02291028&REV_02\4&37cf71d4&0&00F0\LocationInformation

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.
0
 

Author Comment

by:colinmussett
ID: 22948335

i have attached an image with the informatin im trying to retreive, can anyone help with this ?
network-card.png
0
 
LVL 38

Accepted Solution

by:
Shift-3 earned 2000 total points
ID: 22950380
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
Next

Open in new window

0
 

Author Closing Comment

by:colinmussett
ID: 31513447
thanks for that, worked perfectly and helped me along considrably.
regards
colin
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question