I want a shortcut that enable/disable a network card according to its status. I figured out how to enable or disable using either devcon, wmic and pnputil or found some Q&As here that suggest scripts that include conditional code but none of them works for me... the best I managed was to enable it when its disabled but the script doesnt disable it when its enabled...
this is one of the scripts that enable but do not disable:
@echo off
wmic path Win32_PnPEntity get FormFactor|find "2" >nul && goto :disable || goto :enable
goto :eof
:disable
wmic Path Win32_PnPEntity Where "Name='Realtek Gaming GbE Family Controller'" Call Disable
goto :eof
:enable
wmic Path Win32_PnPEntity Where "Name='Realtek Gaming GbE Family Controller'" Call enable
goto :eof
and this is another one
@echo off
for /f "tokens=3" %%a in ('devcon status *DEV_8168^|find "Device is"') do set "status=%%a"
echo status is %status%
IF "%status%" == "running" (
devcon disable DEV_8168
) ELSE (
devcon enable DEV_8168
)
This last one gives me a clue of a kind, when the device is disabled the status query echo %status% returns 'disabled' but when it is enabled it returns nothing rather than 'running', which I believe is what it should return