www.webdeveloper.com
Results 1 to 8 of 8

Thread: VBScript to get a mac address

  1. #1
    Join Date
    Jan 2005
    Posts
    209

    Question VBScript to get a mac address

    I have this script which gets the mac address for the pc who's name I enter:
    On error resume next
    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

    How might I edit this to get more than 1 mac address at a time? Thanks

  2. #2
    Join Date
    Aug 2006
    Posts
    1

    multiple mac addresses ?

    Are you trying to get multiple mac addresses for the same machine or multiple machines or what exactly ?

  3. #3
    Join Date
    Feb 2003
    Posts
    2,745
    put all of the machine names in a text file (or a db), one machine name per line like this
    ------------
    russellsBox_01
    gecko2648sBox_01
    FunkymonkeysBox_11

    Then modify your script like so
    Code:
    Dim fso
    Dim tst
    Dim strMachineName
    
    Set fso = createObject("Scripting.FileSystemObject")
    Set tst = fso.OpenTextFile("c:\listOfMachineNames.txt", 1, false)
    
    While Not tst.AtEndOfStream
    	strMachineName = tst.readLine
    	
    	echoMAC strMachineName
    Wend
    
    Sub echoMAC(strComputer)
    
    	On error resume next
    	' 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
    End Sub

  4. #4
    Join Date
    Sep 2007
    Posts
    3

    Get Mac address

    Is there a vbscript to get all mac address in my network and dump them to a text or excel file?

    Thanks.
    Last edited by julliadarc; 09-12-2007 at 10:12 AM. Reason: error

  5. #5
    Join Date
    Feb 2003
    Posts
    2,745
    you'll need to enumerate the IPs 1st. or you can just iterate through the entire range of valid IP addresses in your network

  6. #6
    Join Date
    Sep 2007
    Posts
    3

    MAc address and local account.

    Hi Russel,

    I was able to get all the mac addresses to a excel file. What I really need now is a script that will read from that file and create local user accounts (not AD accouts) and add them to a local group called "WiredAccess". Each Mac addres will be a local account in my radius server.

    Thanks again.
    Last edited by julliadarc; 09-14-2007 at 06:55 AM. Reason: error

  7. #7
    Join Date
    Mar 2009
    Posts
    1

    vb script to get mac

    Hi julliadarc can i get a copy of your vb script to get the mac addresses.

    thanks

  8. #8
    Join Date
    Sep 2007
    Posts
    3

    vb script to get mac

    Kenuga,

    I did not use a vbscript, but here is a script I found back in 2007. I did not test it and do not guarantee it works. Good luck.
    '--------------------------------------------------------------------------------------------------
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles