Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1790
  • Last Modified:

WIreless Mac Address

When I run the following VBScript , I get the Mac Address for all the Local Area coonection & Wireless. How can I modify the script just to echo ONLY the Wireless one.

Thanks
Cheers

strComputer = (InputBox(" Computer name for MAC address", "Computer Name"))
If strComputer <> "" Then
strInput = True
End if
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objItem in colItems
Wscript.Echo objItem.MACAddress
Next



0
Bianchi928
Asked:
Bianchi928
  • 4
  • 2
1 Solution
 
hieloCommented:
try:
"Select * From Win32_NetworkAdapter WHERE NetConnectionID LIKE '%Wireless%'"

Resource:
http://msdn.microsoft.com/en-us/library/aa394595%28VS.85%29.aspx
0
 
Bianchi928Author Commented:
I've changed to and i get an error

Line 9
Char 1
Error 0x80041004
Code 80041004
Source (null)

Line 9 is the "For each


strComputer = (InputBox(" Computer name for MAC address", "Computer Name"))
If strComputer <> "" Then
strInput = True
End if
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * From Win32_NetworkAdapter WHERE NetConnectionID LIKE '%Wireless%'")


For Each objItem in colItems
Wscript.Echo objItem.MACAddress
Next
 
0
 
spinzr0Commented:
Here is some code I put together for someone last week.  Give it a shot.
On Error Resume Next

sAdminUserName = "username"
sAdminPassword = "password"
sWiFiQuery = "Select MACAddress from Win32_NetworkAdapterConfiguration WHERE Description Like '%WiFi%' OR Description Like '%Wireless%' OR Description Like '%AGN%'"

Set oComputerObject = CreateObject("WbemScripting.SWbemLocator")
oComputerObject.Security_.ImpersonationLevel = 3
oComputerObject.Security_.AuthenticationLevel = 0

sPC = InputBox(" Computer name for MAC address", "Computer Name")

If Ping(sPC) Then
    Err.Clear
    Set oWMI = oComputerObject.ConnectServer(sPC, "root\cimv2", sPC & "\" & sAdminUserName, sAdminPassword)
    If Err.Number <> 0 Then
        oOutputFile.WriteLine "Can't connect to " & sPC & ".  Please check username/password."
        Err.Clear
    Else
        Set cTemp = oWMI.ExecQuery(sWiFiQuery)
        For Each oItem In cTemp
            Msgbox oItem.MACAddress
            Exit For
        Next
        Set cTemp = Nothing
    End If
Else
    Msgbox sPC & " is not currently pingable."
End If
Set oWMI = Nothing

Set oComputerObject = Nothing
Wscript.Echo "Complete."

Function Ping(sHost)
    Dim oWMILocal, cPings, oPing, iPingResult

    Set oWMILocal = GetObject("winmgmts:\\.\root\cimv2")

    Set cPings = oWMILocal.ExecQuery("Select * from Win32_PingStatus " &_
        "Where Address = '" & sHost & "' AND timeout = 500")
    For Each oPing In cPings
        iPingResult = oPing.StatusCode
        If (iPingResult = 0) Then
            Ping = True
            Exit Function
        Else
            Ping = False
        End If
    Next
End Function

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Bianchi928Author Commented:
SPINZR0

ASKED FOR COMPUTER NAME , THEN  DIDN'T DISPLAY ANYTHING, WENT STRAIGHT TO DISPLAY "COMPLETE"
0
 
Bianchi928Author Commented:
SPINZR0

Oops..don't worry. I typed in the wrong admin password..

Thanks
0
 
Bianchi928Author Commented:
Perfect
0
 
spinzr0Commented:
Glad to hear it.  Also, if you change "oOutputFile.WriteLine" to "msgbox" then it will tell you that it failed.  Original code was outputing to a file.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now