简体   繁体   English

如何创建更改我的 MAC 地址的批处理文件?

[英]How can I create a batch file that changes my MAC address?

I recently learned how to change my MAC address thanks to https://superuser.com/questions/1514745/how-to-change-mac-address-on-windows-10-without-third-party-software/1544773 but I was wondering if I could implement this in a batch file.由于https://superuser.com/questions/1514745/how-to-change-mac-address-on-windows-10-without-third-party-software/1544773 ,我最近学会了如何更改我的 MAC 地址,但我想知道我是否可以在批处理文件中实现它。 The registry key for my NIC is HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\0011 .我的 NIC 的注册表项是HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\0011 I want to create a batch file that randomizes my MAC Address.我想创建一个随机化我的 MAC 地址的批处理文件。 You don't need to create the batch file for me (you can, I can't control you), but pointers would be really appreciated.你不需要为我创建批处理文件(你可以,我无法控制你),但指针将不胜感激。

Thanks in advance,提前致谢,

Asian亚洲人

Here is my code, I've done this before.这是我的代码,我以前做过。

@echo off
dism >nul
if %errorlevel% NEQ 0 goto Elevate
(call )
netsh interface set interface Wi-Fi disable
timeout /t 1 /nobreak >null
netsh interface set interface Wi-Fi enable
choice /c RC /m "Would you like to randomize your MAC adress or customize it?"
if %Errorlevel% EQU 2 goto custom
set loopcount=5
:loop
set /a loopcount=loopcount-1
if %loopcount% LEQ 0 (goto exitloop)
set /a "ascii = %random% * 26 / 32768 + 65"
cmd /c exit /b %ascii%
set "rl1=%rl1%%=ExitCodeAscii%
goto loop
:exitloop
set MAC="0E%random:~0,2%%rl1:~0,2%%random:~0,2%%rl1:~3,2%%rl1:~-1%%random:~0,1%"
goto after
:custom
echo What would you like to change your MAC address to?
echo Remember to always have the second digit of your MAC address to always be a 2, 6, A, or E
echo Format: AABBCCDDEEFF
echo/
set /p MAC="Input your MAC address here (no spaces or hyphens)> "
:after
reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\0011" /v NetworkAddress /d %MAC% /f >null
netsh interface set interface Wi-Fi disable
timeout /t 1 /nobreak >null
netsh interface set interface Wi-Fi enable
echo Operation Successful
echo %mac% is your new MAC address
pause
goto :eof
:Elevate
Echo Error: The requested operation requires elevation
Echo Run file again as admin
Echo Closing file in 10 seconds...
timeout /t 10 /nobreak >nul
goto :eof

It sometimes requires a restart before doing it to work but it usually works fine.它有时需要重新启动才能工作,但它通常工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM