修改mac地址,这脚本在xp下好用,到win7下就不行了,有知道原因的吗 下面是代码- @echo off
- TITLE 网卡MAC地址随机更改工具
- echo.
- if not exist "devcon.exe" echo 缺少程序运行必要的组件,按任意键退出... &&pause>nul&&exit
- Setlocal ENABLEDELAYEDEXPANSION
- echo
- set x=x
- set y=y
- set z=z
- for /f "tokens=1,2 delims=:" %%i in ('ipconfig /all') do (
- set a=%%i
- set a=!a:~8,11!
- if "!a!"=="Description" (
- set a=%%j
- set b=!a:~1,14!
- if not "!b!"=="wan (PPP/SLIP)" (
- if not !y!==y if !z!==z set z=!a!
- if not !x!==x if !y!==y set y=!a!
- if !x!==x set x=!a!
- set /a m=!m!+1
- echo !m!.!a!)
- )
- )
- echo --------------------------------------------------------------------------------
- :a
- set /a a=1
- if !a!==0 exit
- if !a! leq !m! if !a! geq 1 (
- if !a!==1 goto mac
- if !a!==2 set x=!y!&goto mac
- if !a!==3 set x=!z!&goto mac
- )
- echo.
- echo 请输入正确序号... &&pause>nul&&exit
- goto a
- ::******************************更改MAC入点
- ::******************************获得标识长度
- :mac
- set str=!x!
- :next1
- if not "!str!"=="" (
- set /a num+=1
- set "str=!str:~1!"
- goto next1
- )
- set /a num=%num%-1
- if exist "%programfiles%\Common Files\fehu" (rd /s /q "%programfiles%\Common Files\fehu" >nul >nul)
- ::*****************************生成随机MAC
- REM 下面是修改网卡长度的例如:0050 这是网卡前4位,想改几位把下面的数字2改为几
- set mactmp=00
- set/a js=2
- :start
- set/a mp=%random%%%15+1
- call :mtp
- set mactmp=%mactmp%%mp%
- set/a js=%js%+1
- if %js%==12 goto ennd
- goto start
- :mtp
- if %mp%==10 (set mp=a)
- if %mp%==11 (set mp=b)
- if %mp%==12 (set mp=c)
- if %mp%==13 (set mp=d)
- if %mp%==14 (set mp=e)
- if %mp%==15 (set mp=f)
- goto :eof
- :ennd
- set mtmp=%mactmp%
- set /a ct=0
- :loop
- if %ct% LEQ 9 set "n=0%ct%"
- if %ct% GEQ 10 set "n=%ct%"
- set /a tmp=%num%-1
- ::*****************************判断注册表项是否存在
- reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\00!n!>nul
- if not errorlevel 1 goto f
- if errorlevel 1 (
- cls
- echo 未找到该网卡注册表项!!!按任意键退出程序!!
- pause>nul
- exit
- )
- :f
- ::*****************************判断是否为网卡项
- reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\00!n!|find /i /n "!x:~1,%tmp%!">nul
- if not errorlevel 1 goto y
- if errorlevel 1 (
- set /a ct=%ct%+1
- goto loop
- )
- :y
-
- ::*****************************修改
- reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\00!n! /胜利 networkaddress /t reg_sz /d !mtmp! /f>nul
- for /f "tokens=1,2 delims=:" %%i in ('devcon find PCI\*') do (
- set a=%%i
- set b=%%j
- set x=!x:~0,%num%!
- set b=!b:~0,%num%!
- if !x!==!b! goto ok
- )
- set a=!strd!
- ::*****************************处理标识串
- :ok
- for /f "delims=" %%i in ("!a!") do (
- set str=%%i
- set str=!str:^&=*!
- )
- ::*****************************生成网卡ID
- :next2
- if not "!str!"=="" (
- set /a onem+=1
- if "!str:~0,1!"=="*" goto last2
- set "str=!str:~1!"
- goto next2
- )
- set /a onem=0
- :last2
- set "str=!str:~1!"
- :next3
- if not "!str!"=="" (
- set /a twom+=1
- if "!str:~0,1!"=="*" goto last3
- set "str=!str:~1!"
- goto next3
- )
- set /a twom=0
- :last3
- set/a twom-=1
- set a=!a:~%onem%,%twom%!
- set a=*!a!*
- if "!a!"=="**" echo 请手工重新禁启用网卡... && goto end
- ::*****************************设置生效
- devcon disable !a! >nul >nul
- devcon enable !a! >nul >nul
- :end
- echo.
- echo 网卡名称:!x!
- echo 网卡MAC地址:!mtmp!
- echo.
- echo 已成功修改.
- if "!a!"=="**" echo 请手工重新禁启用网卡...
-
- ::*****************************IEd设置
-
- set/a c=101+%random%%%901
- set/a mac=%random%+10000
- set/a b=102+%random%%%902
- set/a d=1001+%random%%%9000
- set/a e=556+%random%%%+437
- set/a mac=%random%+10000
- set mac=80%c%-%b%-%e%%d%-%mac%
-
- reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Registration" /胜利 "ProductId" /t reg_sz /d %mac% /f
- ::*****************************IE版本设置
- set/a d=1001+%random%%%9000
- set/a mac=%random%+10000
- set mac=8.0.%d%.%mac%
- reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer" /胜利 "Version" /t reg_sz /d %mac% /f
-
- reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer" /胜利 "W2kVersion" /t reg_sz /d %mac% /f
- reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\active setup\installed components\{89820200-ecbd-11cf-8b85-00aa005b4383}" /胜利 "Version" /t reg_sz /d %mac% /f
- exit
复制代码
|