Jump to content

Mac Changer


Recommended Posts

Its has some bugs , but i cant fix the bugs any one can fix this for me? TIA


Imports Microsoft.Win32
Public Class Form1


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim networkcard As RegistryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}")
Try
'Get all the network cards names and add it to Combo Box


For Each netcard In networkcard.GetSubKeyNames

Dim networkcard2 As RegistryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\" & netcard, False, Security.AccessControl.RegistryRights.ReadKey)
Dim networkcardname As String = networkcard2.GetValue("DriverDesc")

ComboBox2.Items.Add(netcard)
ComboBox1.Items.Add(networkcardname)

networkcard2.Close()
Next
networkcard.Close()
ComboBox1.SelectedIndex = 0
Catch ex As Exception
networkcard.Close()
ComboBox1.SelectedIndex = 0
End Try
End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

'Get the MAC Address of the selected network card
Dim netcardnumber As String = ComboBox2.Items.Item(ComboBox1.SelectedIndex)


Dim getmac As RegistryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\" & netcardnumber, False, Security.AccessControl.RegistryRights.ReadKey)
Dim mac As String = getmac.GetValue("NetworkAddress")

TextBox1.Text = mac
getmac.Close()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try


Dim netcardnumber As String = ComboBox2.Items.Item(ComboBox1.SelectedIndex)
'Using integer in the above will not work

Dim chmac As RegistryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\" & netcardnumber, True)
Dim textmac As String = TextBox1.Text

If textmac.Contains("-") Then
textmac.Replace("-", "")
End If

chmac.SetValue("NetworkAddress", textmac)

chmac.Close()

'Shell("Command.com /c IPConfig/all")

MsgBox("MAC Address changed successfully" & vbNewLine & vbNewLine & "To effect changing MAC Address you need to Disable and Renable the Network card you selected", MsgBoxStyle.Information)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim netcardnumber As String = ComboBox2.Items.Item(ComboBox1.SelectedIndex)

My.Computer.Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\" & netcardnumber, True).DeleteValue("NetworkAddress")
'Shell("Command.com /c IPConfig/all")

MsgBox("MAC Address succesfully resetted" & vbNewLine & vbNewLine & "To effect changing MAC Address you need to Disable and Renable the Network card you selected", MsgBoxStyle.Information)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try

End Sub
End Class

MacAddressChanger.png

Link to comment
Share on other sites


Maybe if you post which kind of error(s) you have, that could help. :whistle:

Also, does something "pre-made" work?

LIke:

http://www.codeproject.com/KB/applications/MacIdChanger.aspx

or one of these?:

http://lantoolbox.com/articles/find-and-change-spoof-your-mac-address-in-windows-xp/

Also, the interrnet is full of examples of similar code, among others:

http://forum.codecall.net/visual-basic-programming/10444-see-change-your-mac-address-visual-basic-net.html

jaclaz

Link to comment
Share on other sites

Here is a Vb.Net 2008 app that list all Network Adaptors

And there Mac Address.

Code


Public Class Form1
Dim Wmi = GetObject("winmgmts:\\.\root\CIMV2")
''' <summary>
''' Load Network Adaptor Info
''' </summary>
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Col = Wmi.ExecQuery("SELECT * FROM Win32_NetworkAdapter")
For Each Obj In Col
Try
If Obj.AdapterTypeId = 0 Then
ComboBox1.Items.Add(Obj.Name)
End If
Catch ex As Exception
End Try
Next
End Sub
''' <summary>
''' Combobox1 Selection Made
''' </summary>
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim Col = Wmi.ExecQuery("SELECT * FROM Win32_NetworkAdapter")
If ListBox1.Items.Count = 1 Then
ListBox1.Items.Clear()
End If
For Each Obj In Col
Try
If Obj.AdapterTypeId = 0 And Obj.Name = ComboBox1.SelectedItem Then
ListBox1.Items.Add(Obj.MACAddress)
End If
Catch ex As Exception
End Try
Next
End Sub
End Class

post-5386-0-56023100-1317340275_thumb.pn

Source Code Zip

Demo_WmiNetwork.zip

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...