Description: |
call:NetworkDeviceName2Guid name guid |
Script: |
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16.
|
:NetworkDeviceName2Guid name guid -- gets a Network Device GUID from its corresponding Name
:: -- name [in] - Network Device Name
:: -- guid [out,opt] - valref to return GUID in
:$created 20060101 :$changed 20080219
:$source https://www.dostips.com
SETLOCAL
set name=%~1
set key=HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}
set ret=
for /f "tokens=*" %%k in ('"reg query "%key%" /s|find /I "}\Connection" "') do (
for /f "tokens=2,*" %%m in ('"reg query "%%k" /v "Name"|findstr /b "....Name" "') do (
for /f "tokens=7 delims=\" %%g in ("%%k") do (
if "%%n"=="%name%" set ret=%%g
)))
ENDLOCAL&if "%~2" NEQ "" (SET %~2=%ret%) ELSE ECHO.%ret%
EXIT /b
|
|