Enable/Disable Network Adapter In Device Manager Using Script
In this tutorial, you will learn how you can Enable/Disable the Ethernet service using shell script and attach the shell script to automatically run on startup and shutdown.
 4-Mar-2023
Created By : Sunil Verma

Enable/Disable Network Adapter In Device Manager

Windows 7 doesn't connect to the Internet on startup. Each time we start up the computer, the Ethernet Network Connection has disappeared from network adapter list and cannot connect to the internet. If I disable and then enable the network adapter from “Device Manager” then it works fine.

I have tried to uninstall the adapter then install it again, and update the driver, but just can't access the internet without disabling and enabling the adapter.

We are going to solve this issue by Running Script at Shutdown and Startup in Windows 7.

Follow the below mentioned steps to troubleshoot this issue:

  • First of all, create the command script (or a batch file) and save it. You should write the script as two batch file though the PowerScript is also supported.

Type following FIRST script without quote in notepad and save the script file as C:\MyEthernet\disable_Ethernet.bat

netsh interface set interface "My_Ethernet_01" disable

Now type following SECOND script without quote in notepad and save the script file as C:\MyEthernet\enable_Ethernet.bat

netsh interface set interface "My_Ethernet_01" enable

  • Re-Name your Ethernet Network Connection as “My_Ethernet_01” as we have used this name in our command script (or batch file).

  • Press the key combination Windows logo key + R to open the Run dialog.

  • In the Run Dialog, type gpedit.msc and press Enter to open the Group Policy Editor.

run


  • In the Group Policy Editor, open Computer Configuration → Windows Settings → Scripts (Startup/Shutdown) as shown. Group Policy

  • Double-click on Shutdown in the right side pane. In the window that opens up, click on the Add button Edit GPolicy

  • Browse to your script file and put in any parameter (only if it accepts parameters). Then click OK button. Ok GPolicy

  • Click OK to close the Shutdown Properties window.

Don’t forget to add this two batch file in Trust List of your Antivirus.

That’s it. Now each time you shutdown the computer, the shutdown script that you have added will run automatically before the computer shuts down and start up.

Note: If you are not able to run scripts at shutdown, then there is a workaround. Try adding scripts to run at log off. When you shutdown, the Windows first logs you off and so log off scripts also run every time you shutdown your computer.