|
本帖最后由 窄口牛 于 2020-1-23 10:02 编辑
一些特定的网络环境需要这种操作
把这个到已经正常的同局域网终端运行,它会生成一个文件夹,里面的批处理到别的同局域网机器就可以使用了
- @echo off
- Setlocal enabledelayedexpansion
- reg query HKU\S-1-5-20>nul || echo;CreateObject^("Shell.Application"^).ShellExecute "%~f0", "%*", "", "runas", 1 > "%temp%\getadmin.vbs" && cscript //b "%temp%\getadmin.vbs" && exit /b & del "%temp%\getadmin.vbs" /f /q>nul 2>nul
- for /f "delims=" %%i in ('wmic nic where "PhysicalAdapter='TRUE'" get InterfaceIndex /value') do (
- for /f "delims== tokens=2" %%a in ("%%i") do (
- for /f "delims=" %%l in ('wmic nicconfig where "InterfaceIndex='%%a'" get DefaultIPGateway /value') do (
- for /f "tokens=2 delims==" %%x in ("%%l") do (
- set "G=%%~x"
- ))))
- set Gate=%G:~2,-2%
- FOR /F "tokens=1,2 delims= " %%a IN ('arp -a^|find "%Gate%"') DO (
- set "GateMac=%%~b"
- )
- md %Gate%专用
- echo @echo off>>%Gate%专用\%Gate%专用绑定mac.bat
- echo Setlocal enabledelayedexpansion>>%Gate%专用\%Gate%专用绑定mac.bat
- echo reg query HKU\S-1-5-20^>nul ^|^| echo;CreateObject^^("Shell.Application"^^).ShellExecute "%%~f0", "%%*", "", "runas", 1 ^> "%%temp%%\getadmin.vbs" ^&^& cscript //b "%%temp%%\getadmin.vbs" ^&^& exit /b ^& del "%%temp%%\getadmin.vbs" /f /q^>nul 2^>nul>>%Gate%专用\%Gate%专用绑定mac.bat
- echo for /f "delims=" %%%%i in ('wmic nic where "PhysicalAdapter='TRUE'" get InterfaceIndex /value') do (>>%Gate%专用\%Gate%专用绑定mac.bat
- echo for /f "delims== tokens=2" %%%%a in ("%%%%i") do (>>%Gate%专用\%Gate%专用绑定mac.bat
- echo for /f "delims=" %%%%l in ('wmic nicconfig where "InterfaceIndex='%%%%a'" get DefaultIPGateway /value') do (>>%Gate%专用\%Gate%专用绑定mac.bat
- echo for /f "tokens=2 delims==" %%%%x in ("%%%%l") do (>>%Gate%专用\%Gate%专用绑定mac.bat
- echo set Index=%%%%a>>%Gate%专用\%Gate%专用绑定mac.bat
- echo ))))>>%Gate%专用\%Gate%专用绑定mac.bat
- echo netsh -c "i i" delete neighbors %%Index%%^>nul>>%Gate%专用\%Gate%专用绑定mac.bat
- echo netsh -c "i i" add neighbors %%Index%% %Gate% %GateMac%^>nul>>%Gate%专用\%Gate%专用绑定mac.bat
复制代码
打包下载
永久绑定网关MAC生成.rar
(738 Bytes, 下载次数: 36)
|
|