Enable/Disable batch processing of Ethernet for one NIC switch on-premises network and WiFi usage (WIN10)

Source: Internet
Author: User

Note the following when the English version of the default network use, while connected to the network cable and WiFi, local networks priority WiFi.

So disabling the local network will automatically connect to WiFi, enabling the local network and disabling WiFi.

The batch supports the-slice parameter with the following code:

Switchethernet.bat

1 @echo off2pushd "%~dp0"3 SetName= "Ethernet"4 Setfindtext= "Administrative state:enabled"5 6"%systemroot%\system32\cacls.exe" "%SystemRoot%\System32\Config\SYSTEM" >nul 2>nul7 if%ERRORLEVEL%==0Goto : START8 9 Echo* * please UseAdministrator account toRun. **Ten Goto : END One  A : START - Setinput= - SetSlice=0 the if"%1" = = "-slice"SetSlice=1 -netsh interface show interface name=%name% -netsh interface show interface name=%name% |Find%findtext% >nul - if ERRORLEVEL1Goto : op_enabled + : op_disabled - Echo. + if%slice% equ 1Goto : Op_d_skip A Set/P input=input ' Y ' to DISABLE interface%name% [y/N]: at Goto : Op_d_run - : Op_d_skip - EchoInput ' Y ' to DISABLE interface%name% [y/n]: Y - Setinput=Y - : Op_d_run - if/I "%input%" = = "Y" netsh interfaceSetInterface Name=%name% admin=DISABLED in Goto : END - : op_enabled to Echo. + if%slice% equ 1Goto : Op_e_skip - Set/P input=input ' Y ' to ENABLED interface%name% [y/N]: the Goto : Op_e_run * : Op_e_skip $ EchoInput ' Y ' to ENABLED interface%name% [y/n]: YPanax Notoginseng Setinput=Y - : Op_e_run the if/I "%input%" = = "Y" netsh interfaceSetInterface Name=%name% admin=ENABLED + Goto : END A : END the Echo. + EchoCurrent Status: - netsh interface show interface $ if%slice% equ 1Goto : Skip_any_key $ EchoPress any key toExit... - Pause>nul - Goto : End1 the : Skip_any_key - EchoWouldExitIn 5 seconds ...WuyiPing 127.1-n 6 >nul the : End1 -popd

Enable/Disable batch processing of Ethernet for one NIC switch on-premises network and WiFi usage (WIN10)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.