IPv6- Windows Server 2012 batch批处理修改DHCPv6注册表参数
從來沒接觸過這東西,一點點查,慢慢編譯才出來。
1? 獲取mac地址并將轉化成DUID-LL
@echo off
for /f "skip=14 tokens=1,2* delims=:" %%a in ('ipconfig /all') do set "b=%%b"&goto a
:a
echo %b% >> mac1.txt
for /f "tokens=1-6 delims=-" %%a in (mac1.txt) do echo %%a,%%b,%%c,%%d,%%e,%%f>> mact2.txt
del mac1.txt
??????????????????????????????????????????????????????????????????????????????????????????????????????????????? //此時mac2.txt中的mac格式為11,22,33,44,55,66
set pre=00,03,
for /f %%a in (mac2.txt) do ( echo %pre%%a>>mac3.txt )
del mac2.txt
?????????????????????????????????????????????????????????????????????????????????????????????????????????????? //此時mac3.txt中的mac地址會是00,03,11,22,33,44,55,66
2? 傳入參數,創建并執行注冊表.reg文件
for /f %%i in (mac3.txt) do (echo %%i) & set mac=%%i
echo Windows Registry Editor Version 5.00>test.reg
echo.
echo [想要修改的注冊表文件所在目錄]>>test.reg
echo "文件名"=hex:%mac% >>test.reg
echo "Type"=binary>>test.reg???????????????????????????????????????????????????? ? ?? ? //此處的類型是所要修改的文件類型
regedit /s test.reg
del /q test.reg
del /q mactem3.txt??????????????????????????????????????????????????????????????????????????? //執行.reg文件并刪除生成的臨時文件
3? 禁用啟用網卡
for /f "tokens=4 delims= " %%i in ('netsh interface show interface') do (set inf=%%i)
echo %inf%
for /f "tokens=5 delims= " %%a in ('netsh interface show interface') do (set num=%%a)
echo %num%
if "%num%"==" " (
? netsh interface set interface "%inf%" disabled
? ping -n 5 127.0.0.1
? netsh interface set interface "%inf%" enabled
)
if not "%num%"==" " (
? netsh interface set interface "%inf% %num%" disabled
? ping -n 5 127.0.0.1
? netsh interface set interface "%inf% %num%" enabled
)
exit??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? //bat腳本的結尾
4? 設置腳本的開機自啟
編輯test.vbs文件,內容如下:
set ws=WScript.CreateObject("WScript.Shell")
ws.Run "bat腳本的絕對路徑 /start",0
將test.vbs文件放在C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\目錄下即可。
轉載請注明出處,謝謝!
總結
以上是生活随笔為你收集整理的IPv6- Windows Server 2012 batch批处理修改DHCPv6注册表参数的全部內容,希望文章能夠幫你解決所遇到的問題。