Three ways to modify the MAC address of windows system

Method 1: Use the windows control panel to modify

The first step is to press the win key> enter "Control Panel" and open it.

Insert picture description here

The second step is to open "Network and Sharing Center"

Insert picture description here

The third step is to open "change adapter settings"

Insert picture description here

Step 4 Right-click "WLAN2" and click Properties

Insert picture description here

The fifth step is to modify the properties of the network address

Click Configure, click the "Advanced" tab, find the "Network Address" property below, set the value to the new Mac address, and click OK. If you do not find the "Network Address" attribute, you need to modify the information in the registry first. The modification method is at the end of this article! ! !
Insert picture description here
Insert picture description here

Method 2: Use the command line to modify

The first step is to modify the NetworkAddress attribute in the test table

Enter the following command in cmd:

reg add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Class\\{
    
    4d36e972-e325-11ce-bfc1-08002be10318}\\0004 /v NetworkAddress /t REG_SZ /d {
    
    你要设置的MAC地址}

The second step is to restart the network card

Enter the following two commands in cmd:

netsh interface set interface "{网络适配器名称}" disabled
netsh interface set interface "{网络适配器名称}" enabled

In which the network adapter name can be mentioned a method in the Control Panel> Network and Sharing Settings> Change adapter option to view, you can also use the command line ipconfig /allto view.

Method 3: Use programming language to encapsulate, take Java as an example.

We can use some high-level programming languages ​​to call the command line commands in Method 2 to achieve a one-click program to switch the computer's MAC address .
First of all, we can implement a random MAC address generator, which makes the program generate a new MAC address every time it runs. For some reasons, the generator code is not given here.

public static class RandomMACAddressGenerator {
    
    
       public String randomMACAddress() {
    
    
			return null;
		}		
   }

Call the command line command to modify the registry code:

 public static void changeMAC(String newMACAddress) throws IOException {
    
    
        String cmd = "reg add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Class\\{4d36e972-e325-11ce-bfc1-08002be10318}\\0004 /v NetworkAddress /t REG_SZ /d "
                + newMACAddress
                + " /f";
        Process process = Runtime.getRuntime().exec(cmd);
        log(process);// 输出命令行运行输出
        System.out.println("成功改变MAC为:" + newMACAddress);
    }

Invoke the command line command to restart the network card:

 public static void rebootNetworkCard() throws IOException {
    
    
        String disabledCmd = "netsh interface set interface \"WLAN 2\" disabled";
        String enabledCmd = "netsh interface set interface \"WLAN 2\" enabled";
        final Process disabledProcess = Runtime.getRuntime().exec(disabledCmd);
        log(disabledProcess);// 打印命令行运行输出到控制台
        final Process enabledProcess = Runtime.getRuntime().exec(enabledCmd);
        log(enabledProcess);// 打印命令行运行输出到控制台
    }

Additional: What should I do if there is no "network address" option in the advanced properties?

The first step is to press the win key, enter "Registry Editor" and open it.

Insert picture description here

The second step is to find the network card that needs to be modified in the registry

Enter the following path in the input box at the top of the registry, and hit enter:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{4d36e972-e325-11ce-bfc1-08002be10318} Insert picture description here
Then you will see a series of numbers named in the directory Folder (as shown above), look for the network card we need to modify in turn. Finding method: Click on the small directory on the left, and then check the DriviceDesc attribute on the right, and find the same item as described in our WiFi hardware attribute.

Insert picture description here
Insert picture description here

The third step is to create a new NetworkAddress attribute item

Right-click Ndi>Params of the folder corresponding to the network card, and click New>Item.
Insert picture description here
Name the newly created item NetworkAddress and write the following properties. Then save and exit, the corresponding location in the settings will have the network address attribute.
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_44525150/article/details/114902469