Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Get the PC Physical Address or Mac Address

  Asked By: Clark    Date: Oct 19    Category: MS Office    Views: 1071
  

Is there any macro's routine or functions to pick up a PC physical address? This
address could be obtained when you press start button and type 'cmd' on run
command (input box). Then keyin 'ipconfig /all' then ENTER.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Jeanette Greene     Answered On: Oct 19


There are two ways to get this from the local host with relative ease.
First, you could use WMI or, second, you can shell out a CMD prompt and
capture IPCONFIG to a text file, parse it, get what you want and delete it.

The following is WMI code for revealing all the current NIC data for all
Nics on a host in WMI:
'Get a connection to the WMI NetAdapterConfig object
Set NIC1=GetObject("winmgmts:{ImpersonationLevel=Impersonate}\\" & _
".").InstancesOf("Win32_NetworkAdapterConfiguration")

'For Each of the NICs in the connection
For Each Nic in NIC1
'Get the Adapter Description
StrNIC = Nic.Description
'If IP is enabled on the NIC then let's find out about the NIC
IF Nic.IPEnabled THEN
lngCount=UBound(Nic.IPAddress)
For i=0 to lngCount
If i >= 0 Then
debug.print "==================================" & _
vbNewLine
debug.print StrNic & vbNewLine
StrIP = vbTab & Nic.IPAddress(i)
If StrIP <> "" Then
debug.print vbTab & "IP address  = " & _
StrIP

debug.print vbTab & "MAC Address = " & _
Nic.MACAddress

debug.print vbTab & "NIC Service (Short) Name = " & _
Nic.ServiceName

debug.print vbTab & "IP Subnet(s): "
For j = 0 to UBound(Nic.IPSubnet)
debug.print vbTab & vbTab & Nic.IPSubnet(j)
Next

debug.print vbTab & _
"Internet Database Files Path = " & _
Nic.DatabasePath

debug.print vbTab & "Dead Gateway Detection = " & _
Nic.DeadGWDetectEnabled

debug.print vbTab & "IP Gateway(s): "
For j=0 to UBound(Nic.DefaultIPGateway)
debug.print vbTab & vbTab & Nic.DefaultIPGateway(j)
Next

If Nic.DHCPEnabled Then
debug.print vbTab & "DHCP Assigned IP address = " & _
Nic.DHCPEnabled

debug.print vbTab & "DHCP Server = " & _
Nic.DHCPServer
End If

debug.print vbTab & _
"DNS for WINS Resolution Enabled = " & _
Nic.DNSEnabledforWINSResolution

debug.print vbTab & "DNS Host Name = " & _
Nic.DNSHostName

debug.print vbTab & "DNS Servers:"
For j=0 to UBound(Nic.DNSServerSearchOrder)
debug.print vbTab & vbTab & Nic.DNSServerSearchOrder(j)
Next

debug.print vbTab & "IP Port Filtering Enabled = " & _
Nic.IPFilterSecurityEnabled

If Nic.IPFilterSecurityEnabled Then
debug.print vbTab & "IP Filtering Enabled."

If Nic.IPSecPermitIPProtocols <> 0 Then
For j=0 to UBound(Nic.IPSecPermitIPProtocols)
debug.print vbTab & vbTab & "Protocol: " & _
Nic.IPSecPermitIPProtocols(j)
Next
Else
debug.print vbTab & vbTab & "No Protocols Filtered"
End If

If Nic.IPSecPermitTCPPorts <> 0 Then
For j=0 to UBound(Nic.IPSecPermitTCPPorts)
debug.print vbTab & vbTab & "TCP Port: " & _
Nic.IPSecPermitTCPPorts(j)
Next
Else
debug.print vbTab & vbTab & "No TCP Ports Filtered"
End If

If Nic.IPSecPermitUDPPorts <> 0 Then
For j=0 to UBound(Nic.IPSecPermitUDPPorts)
debug.print vbTab & vbTab & "UDP Port: " & _
Nic.IPSecPermitUDPPorts(j)
Next
Else
debug.print vbTab & vbTab & "No UDP Ports Filtered"
End If

End If

debug.print vbTab & "LMHOSTS Lookup Enabled = " & _
Nic.WINSEnableLMHostsLookup

debug.print vbTab & "WINS Lookup File = " & _
Nic.WINSHostLookupFile

debug.print vbTab & "Primary WINS Server = " & _
Nic.WINSPrimaryServer

debug.print vbTab & "Secondary WINS Server = " & _
Nic.WINSSecondaryServer

debug.print vbTab & "WINS Scope ID = " & Nic.WINSScopeID

End If
End If
Next
END IF
Next

 
Didn't find what you were looking for? Find more on Get the PC Physical Address or Mac Address Or get search suggestion and latest updates.




Tagged: