Solved

WIreless Mac Address

Posted on 2010-09-06
7
1,699 Views
Last Modified: 2012-05-10
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
Comment
Question by:Bianchi928
  • 4
  • 2
7 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 33614176
try:
"Select * From Win32_NetworkAdapter WHERE NetConnectionID LIKE '%Wireless%'"

Resource:
http://msdn.microsoft.com/en-us/library/aa394595%28VS.85%29.aspx
0
 

Author Comment

by:Bianchi928
ID: 33614254
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
 
LVL 8

Accepted Solution

by:
spinzr0 earned 125 total points
ID: 33614480
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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:Bianchi928
ID: 33614523
SPINZR0

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

Author Comment

by:Bianchi928
ID: 33614547
SPINZR0

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

Thanks
0
 

Author Closing Comment

by:Bianchi928
ID: 33614548
Perfect
0
 
LVL 8

Expert Comment

by:spinzr0
ID: 33614584
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

777 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