greetz,
im facing an issue where i want to accomplish something (enabling to display the network connection status in the taskbar) but for me to be able to write the correct registry key, i need ot retrieve the GUID of the network device.
my question is, is there a trick on how to retrieve the GUID?
i found the following script but for some reason, it doesnt seem to work any ideas?
http://www.jsifaq.com/SF/Tips/Tip.aspx?id=8270
regards
Matice
any idea howto retrieve the GUID of network card in a script
Moderator: DosItHelp
Matice,
Use the :NetworkDeviceName2Guid function in you main code like this:
Copy the :NetworkDeviceName2Guid function from here:
http://www.dostips.com/DtCodeCmdLib.php#NetworkDeviceName2Guid
to the end of your batch file.
DOS IT HELP?
Use the :NetworkDeviceName2Guid function in you main code like this:
Code: Select all
CALL:NetworkDeviceName2Guid "Local Area Connection" guid
ECHO.The GUID is: %guid%
GOTO:EOF
Copy the :NetworkDeviceName2Guid function from here:
http://www.dostips.com/DtCodeCmdLib.php#NetworkDeviceName2Guid
to the end of your batch file.
DOS IT HELP?
greetz,
for some reason i wasnt able to get it to work, i guess it has to do with the different reg.exe version being used in different OS, in my case windows server 2003.
here is what i was able to cut down to:
ECHO # Enabling "Show Icon in Notification Area When Connected" for WEB, SRVR and BKP NIC Interfaces
reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318} /s|findstr "\Connection"|sed -e "s/HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\//g"|sed -e "s/\\Connection//g" > c:\nicguid.txt
for /f %%i in (c:\source\nicguid.txt) do reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\%%i\Connection /v Name|findstr /I "WEB SRVR BKP" > NUL && if errorlevel 0 ECHO FOUND PROD NIC CONFIGURING .. && REG.EXE ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\%%i\Connection" /f /v "ShowIcon" /t REG_DWORD /d "1"
del c:\nicguid.txt
echo Modifications applied and will be active on next boot!
i guess that could be improved and use something other than sed but i just found sed easier.. bash is just so much easier and more flexible.. well at least it has more documentation to the different tweaks available.
this site has some very impresive implementations that i have not seen elsewhere.
your kungfuu is strong!!!
regards
Matice
for some reason i wasnt able to get it to work, i guess it has to do with the different reg.exe version being used in different OS, in my case windows server 2003.
here is what i was able to cut down to:
ECHO # Enabling "Show Icon in Notification Area When Connected" for WEB, SRVR and BKP NIC Interfaces
reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318} /s|findstr "\Connection"|sed -e "s/HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\//g"|sed -e "s/\\Connection//g" > c:\nicguid.txt
for /f %%i in (c:\source\nicguid.txt) do reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\%%i\Connection /v Name|findstr /I "WEB SRVR BKP" > NUL && if errorlevel 0 ECHO FOUND PROD NIC CONFIGURING .. && REG.EXE ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\%%i\Connection" /f /v "ShowIcon" /t REG_DWORD /d "1"
del c:\nicguid.txt
echo Modifications applied and will be active on next boot!
i guess that could be improved and use something other than sed but i just found sed easier.. bash is just so much easier and more flexible.. well at least it has more documentation to the different tweaks available.
this site has some very impresive implementations that i have not seen elsewhere.
your kungfuu is strong!!!
regards
Matice
DosItHelp wrote:Matice,
Use the :NetworkDeviceName2Guid function in you main code like this:Code: Select all
CALL:NetworkDeviceName2Guid "Local Area Connection" guid
ECHO.The GUID is: %guid%
GOTO:EOF
Copy the :NetworkDeviceName2Guid function from here:
http://www.dostips.com/DtCodeCmdLib.php#NetworkDeviceName2Guid
to the end of your batch file.
DOS IT HELP?