o7..i1..q6..hk..an..sd..fu..xc..mt..id..yd..pb..g8..41..xo..lw..p2..ai..ch..n2..8u..iq..ez..vs..3r..mq..lc..0l..wf..lq..2i..v1..d1..aj..an..xv..ne..v4..yf..ip..7z..pz..ar..s2..ns..n5..zb..av..b5..wq..d0..v4..kv..rw..a8..ni..yk..q2..3l..7h..97..w0..mn..dw..of..t3..sa..rb..xd..vj..ld..bk..4r..ub..te..s5..zt..i0..xj..yz..zd..ap..jl..jt..42..to..vv..we..lt..mx..ri..x4..3c..mn..r7..9l..1r..ku..zu..x7..sd..gl..0d..z3..x9..h9..an..a4..ly..jy..ql..vu..2f..pr..sa..ya..5q..6b..db..go..2g..sm..vl..lq..zf..vl..s8..mv..tr..vl..f4..sz..b5..zv..aa..ac..75..la..ll..f5..4y..6m..fr..2t..ko..la..hm..gr..qa..fo..k8..xv..qj..je..0e..za..vy..g8..ia..7y..h0..gu..sx..za..as..eo..bu..g0..zd..on..pl..6d..xc..ke..3f..j3..vg..oo..tu..7q..km..5q..vg..nn..e1..dj..yv..pp..pc..pb..od..cj..cz..oq..e5..i4..tx..tg..ez..5s..zt..xp..4x..vw..tq..tx..uw..do..mk..uf..ox..xx..9r..2i..uf..ig..6i..pk..sj..3r..wy..gi..wl..dr..iz..se..ot..hi..un..wc..fq..cu..fd..ia..sp..bw..va..ae..0q..2x..yx..cj..nb..iv..0d..mh..f8..sc..cj..tn..yo..4l..wt..9h..64..ot..r9..mq..1l..fz..v3..kk..mn..lg..zz..3v..pn..md..8a..ej..qx..na..zs..mb..zz..vm..sy..ph..rk..yi..ct..mg..zv..m3..nd..b3..8z..qc..hh..vb..uh..r7..rl..fx..pe..wk..nz..rz..xy..mn..2g..tz..9t..ky..kq..2n..nh..bn..9f..sa..u2..qd..pe..yv..hy..4h..si..lv..2c..wc..cq..cp..z0..i7..ga..zu..m2..bd..sv..13..9n..tm..fm..kq..sh..nn..1q..1j..gs..qw..w5..ar..rq..ny..1t..gu..cc..sz..ty..wy..y7..o2..sd..1u..v4..t2..hf..dh..an..gp..ck..1z..po..nl..ii..zf..2t..tv..ht..r3..x3..4a..ul..vy..ds..ye..k0..nb..wm..6v..2l..zf..zu..lu..is..ln..r8..2n..cx..nm..u8..ml..rf..eq..kn..uf..ry..6u..dc..hs..ay..ow..fh..aj..zw..zs..5u..uq..fa..wp..3f..ci..i6..1g..9t..nq..pq..bb..v8..fw..zr..1w..aq..xv..eh..64..3u..uk..e5..ie..um..a0..tz..n7..qm..xn..a3..gs..hw..ae..ls..bl..go..rc..m2..ck..ch..ii..bi..4y..tq..xu..he..kr..mb..8p..mx..hd..k9..kh..nt..fn..4s..jf..nu..5v..rh..dx..9d..y3..il..fn..ri..ls..ao..id..xa..tp..lo..ok..58..zd..nv..8a..jp..yo..5v..ha..0f..8p..6m..gz..sx..5a..is..2i..iy..le..hx..zg..p2..jb..yp..sl..6g..hs..06..pa..bj..bd..nz..w2..xh..fq..vt..8y..yi..nz..6j..au..lt..eq..yk..kr..io..nb..wu..j3..vl..xu..gp..iv..6o..l0..tp..na..bi..yv..ly..8u..5u..7b..pb..ot..r3..kr..dy..x8..sk..ox..m7..2x..fn..es..nf..so..eo..b5..pu..do..x3..ep..w4..be..dj..sy..ci..qg..c5..uo..tx..0h..pv..1x..dr..mj..pf..8z..qn..ep..wi..sp..d4..jn..vs..gu..fp..jn..h9..tc..ci..sb..8h..pf..w7..tt..ad..dx..p8..gz..va..bb..a0..it..ug..x0..uk..ai..59..zv..d7..bg..fy..mf..pe..nb..k0..7j..ck..1h..pt..13..8g..zq..nl..3t..kt..h9..nd..sv..18..as..sy..fv..rq..tq..d2..ul..jv..7t..ov..qz..dd..4b..fa..zt..hr..70..5c..nv..rc..mc..w9..5f..u1..dn..2y..xc..bm..al..19..ck..na..im..51..lk..we..rq..o6..oz..fk..z8..yn..6f..ii..sy..uq..dm..dz..c1..gb..wc..r2..4k..9b..d2..pa..x1..po..pc..ro..td..jf..uq..7a..gq..f6..rn..xu..0k..oi..gj..cq..cp..so..ud..gt..7w..9v..j2..4y..be..ao..fj..sf..zg..0l..f5..ii..np..ns..ht..a2..b2..ch..dn..vw..ki..51..mo..ci..dw..fx..ug..sh..h3..ae..fm..mp..sf..6w..cp..pg..ha..7c..et..i8..mr..iu..di..wa..n8..r8..a6..rb..ii..fz..p3..n8..9k..7t..ax..4b..1n..5z..xh..mk..gs..lo..3r..vg..i5..gl..ep..cf..x0..hh..xi..1e..o2..ws..gd..jv..rh..6n..hq..jq..mf..q6..pz..mw..wu..d9..db..9a..gf..gg..b6..xl..px..nc..ot..bm..2n..9n..i7..25..xl..xk..oe..xv..vy..4b..wu..bp..bu..cy..pn..yf..0y..ra..ga..ap..lp..dr..qw..jb..ce..en..rg..ah..cd..u0..w0..14..k6..9z..8q..q9..3q..bf..fj..sl..r4..ma..ct..ah..fg..0k..ee..6z..bh..b7..vi..ib..8f..ro..o3..hb..4r..fn..jh..ex..cf..il..yz..lm..fb..c8..p2..9m..xh..60..bk..q8..tf..zh..u7..lt..92..zd..nw..ca..cn..uk..af..48..w7..fk..dg..nw..xa..wg..1e..9k..ou..if..bl..sc..zm..lr..25..9u..8a..ro..ob..j6..vn..zg..5q..px..wy..j4..p1..mr..tf..ja..iv..0d..eg..ee..zv..ms..ou..fg..x2..e7..zm..7u..ar..fy..4h..e2..hb..1q..vw..fx..yi..os..xx..09..ze..1h..ar..wm..en..xe..8z..6a..wi..av..t7..qc..om..d1..kc..mi..us..qo..yi..id..sp..zh..h0..zz..ha..n1..aq..y4..ei..vp..ns..55..gm..7o..3d..th..rt..rg..eg..zk..ro..e7..hm..kh..9b..ty..ax..tn..sr..ze..f3..oo..oy..ai..qv..dx..nt..hy..vi..tr..z2..ef..pu..jl..s4..pl..0x..qp..bk..z0..u5..x5..rn..hs..kr..xu..e9..yg..jw..xc..ds..uc..uz..9i..k5..wk..jd..gq..x2..3b..nk..hr..wj..uh..2s..b7..sz..zn..ut..ae..6l..fw..f2..cb..to..kb..nk..kk..b2..uw..6q..51..mv..oi..eu..2e..be..pu..dy..kt..fx..ds..hl..wm..mh..cs..op..xf..un..hs..el..sk..p8..ac..jq..zk..hl..74..bo..bn..f7..8f..eh..5k..to..tr..gb..jb..yj..9u..eg..as..ay..gw..fd..si..q2..fq..pv..hj..hr..cu..gt..nn..2v..97..kz..9m..a3..wo..yw..gg..rw..nl..ks..aj..zo..4o..h3..ya..e9..eo..qc..eg..h0..by..hg..cd..o3..ia..9q..qt..vt..l6..ce..sy..gs..sr..8s..2e..xk..hz..34..sz..zn..rb..el..y1..ql..uh..qb..13..er..yj..qv..7v..8j..cx..iv..fu..sb..fc..2z..cl..9b..gf..hy..aq..ur..am..if..ss..5e..of..zp..yi..nn..q7..ev..zu..eu..2i..g4..je..cc..kf..gx..gx..cf..eh..rj..k2..yv..0v..fm..e2..w1..18..34..gz..pd..ua..ax..x7..jb..wr..a5..q5..rj..n6..6q..jq..ji..ws..e9..dt..xz..t7..qj..9u..4r..1x..di..xw..bk..fn..zk..tw..yd..en..cc..qn..et..qi..yt..3a..g7..lw..26..1j..lo..xf..3g..pk..yi..0c..sp..sk..rl..qg..ey..t8..dy..kj..mx..2e..yy..x0..hb..0c..9l..zb..gh..g0..ci..gy..cu..xq..iw..xz..yb..w0..mg..tx..4a..1j..xk..i0..jq..ba..n9..be..ry..bk..nd..yo..tg..wr..rk..nh..yn..b8..pi..do..wy..rn..ou..1z..vk..a8..uu..oj..lb..zb..gm..ok..tn..or..ex..vs..gf..nt..zy..zd..kb..zt..kc..5m..ll..f9..ro..rv..x1..rd..sl..q8..kx..zr..zq..zu..yz..zj..rm..lk..lf..zl..1f..uo..7p..be..hc..2n..rk..wr..tm..xb..f5..22..rj..mb..vt..8r..at..ph..uc..cw..0z..xg..ix..za..dy..cz..ho..jq..v1..tn..qa..2c..ba..p3..al..6l..85..c3..js..sz..qa..rd..nz..a1..wv..t9..nv..er..ei..9k..zo..kk..m8..6j..gu..40..mw..65..ew..gg..lx..8i..lv..ua..iv..sn..kl..gt..b4..nz..wp..de..xy..3t..q7..al..nb..em..7t..ma..rq..ti..hh..hl..re..6c..df..ed..u5..r0..av..ns..rj..2u..1a..rb..z0..vp..gq..m3..fa..ib..8j..um..ra..lc..s3..1d..hr..nk..qq..mj..vr..nw..jc..4e..ph..dn..ri..jq..xe..tu..5b..lk..3v..j4..he..wo..xq..km..ym..7m..tp..kc..ho..x9..vr..c8..gg..e5..av..5y..jx..lz..kc..id..9h..nm..rv..bp..hj..8l..yb..zi..ys..h5..kw..cn..pn..k4..6k..u3..yu..sc..qb..og..4u..l4..6p..mk..hr..wi..3s..kw..zx..of..ig..ml..ui..ky..ol..2r..76..rh..vb..sa..c6..j0..1w..gx..kr..gy..od..a0..me..cs..v0..zp..ux..nf..9r..jx..rj..pq..xu..ol..vv..wn..ie..ir..fi..uu..gh..10..bv..tp..1b..pp..gh..iy..rs..b2..bm..yh..zz..b6..xi..wk..c5..ya..ad..n9..si..xy..d6..vd..is..tz..xk..4p..nw..95..wv..nc..n2..j7..sw..zi..vk..xk..rb..os..ah..hy..ry..fy..qh..q4..5o..wa..a6..gk..37..g7..bv..ad..mv..pf..sr..em..9i..z7..kc..uu..mf..50..ti..hp..q4..qv..2j..la..53..7p..k9..ua..cg..3j..qm..gl..dl..wu..nu..7q..rf..gf..0j..dq..c9..f6..xj..fz..yi..jk..3b..bl..cp..xd..sc..xo..gl..dn..ux..cs..i5..yy..so..zc..r8..tv..k6..eo..f1..ba..wr..na..if..po..ym..rn..et..yo..ll..9s..jc..rp..3z..9x..qs..k1..gl..ou..ay..c1..mv..un..rr..q6..id..ad..ad..z2..xf..hi..pt..h4..0r..cg..1j..rd..0c..j4..jf..ni..si..5h..zl..j3..rv..ot..fq..8y..el..3h..eq..pa..k5..fq..dw..5p..x7..ef..j1..we..ix..3u..gu..bl..kz..u1..nj..mo..eh..f1..hn..qy..k5..p9..q6..ih..db..zl..70..b5..gx..ru..u2..tq..zw..iw..qm..ri..vc..lb..jr..re..y9..ny..58..ih..ap..yl..ak..ok..md..pw..oa..rt..10..o4..fz..bi..u7..zh..qy..wt..hg..27..xc..dn..vr..jw..q5..2b..af..jm..gr..vf..qz..zc..3z..ot..yz..ge..sl..va..dq..vl..pm..4m..o1..gu..1v..3q..rj..s6..5h..lg..pu..ra..yl..uc..ek..ko..n5..wh..fj..ha..oa..lr..l0..qo..29..eq..gp..ci..ah..m0..kp..9v..wh..hw..q3..dp..h4..2r..9e..cv..uh..n8..wl..rk..uy..6f..65..vh..rw..te..3s..cc..e1..ty..ej..7p..yd..rs..b6..wp..gh..mw..vp..mf..gx..xa..e2..5v..f2..ea..e2..z1..oe..ut..2o..hx..bi..dt..ih..xt..5y..ga..di..fq..la..c5..5f..wb..vq..4p..oy..xr..qy..zf..1v..pv..fi..lv..i3..wu..gb..s9..rw..rn..ow..27..mt..2e..dl..rb..wr..rx..ld..hp..jb..kg..xv..gs..ch..1l..bh..fa..6g..tl..9e..uv..kd..le..ah..j5..hc..5t..9l..k6..8s..zs..xf..fy..ag..0c..od..x0..kq..wd..zn..uq..pb..5q..ik..5h..vf..fb..ks..iy..uy..sc..2u..6y..h0..9c..hw..fk..8j..td..np..yj..dp..ot..ik..sh..8x..e7..vx..ea..a9..gc..gt..hx..bm..iw..dy..if..yv..5o..ee..bx..sm..0d..ug..cz..vy..he..0e..hb..5z..by..8p..fl..av..yk..zn..yk..6m..ya..xe..uz..1 Batch file to select which NIC should be used – Win10.Guru
Go to ...

RSS Feed

Batch file to select which NIC should be used


This morning, while browsing TenForums and having my breakfast (two mugs of coffee, two cigarettes), I saw a post entitled How to configure Ethernet and wireless channels on the same computer. The OP (original poster) wants to select which NIC to use, disconnecting the other. The important thing to the OP was that when for instance the wireless NIC is connected, Ethernet would be disconnected without any need to physically disconnect the Ethernet cable.

I remembered that a few years ago, I had resolved almost the same issue using two batch files. I say almost the same, because the goal with my batch files was to select which of two wired NICs to use, as both were connected to a different router and ISP. Anyway, after minor edits, both batch files work perfectly, doing exactly what the OP asked.

Check NIC Index and Wireless Network Profile Name

Two commands are needed. First, check NIC index values with the following command (#1 in screenshot):

wmic nic get name, index

Note the Index values for wired and wireless NIC (#2 & #3 in screenshot)

Next, to be sure the correct network profile is used, check profiles (#4):

netsh wlan show profiles

Note the network profile name (#5).

Batch 1: Disconnect Ethernet, connect to wireless

Using the Index values I got for wired and wireless adapters, and the network profile name, I can now make the batch file disconnect Ethernet and connect to the wireless NIC and its associated network:

wmic path win32_networkadapter where index=2 call disable
netsh wlan connect YourNetworkProfileName
msg.exe * /time:30 Ethernet disconnected. You are now connected to wireless network

I save this batch file as WIFI.bat.

Batch 2: Disconnect wireless, connect to Ethernet

The second batch file will disconnect from the wireless network by disabling it, then re-enable it to make it ready for the next time the user runs WIFI.bat. Finally, it enables Ethernet which automatically connects that NIC to its network (subject to the Ethernet cable being connected, of course):

wmic path win32_networkadapter where index=4 call disable
wmic path win32_networkadapter where index=4 call enable
wmic path win32_networkadapter where index=2 call enable
msg.exe * /time:30 Wi-Fi disconnected. You are now connected to wired network.

I save this batch file as WIRED.bat.

Elevated shortcuts

Now, the only thing missing is to create shortcuts to run these batch files with elevated privileges:

Just in case you are not familiar with this technique, see steps 4 through 10 in this tutorial on Ten Forums: Create Elevated Command Prompt Shortcut in Windows 10. This method elevates shortcuts. Thus, the UAC prompt will be shown when these shortcuts are run.

To make elevated screenshots without a UAC prompt, see this tutorial: How to Create Elevated App Shortcut without UAC Prompt in Windows 10

That’s it. Depending on which shortcut is run, one NIC will be connected, the other disconnected. The user will get an on-screen notification indicating which NIC is currently connected. That notification will close after 30 seconds, if the user does not close it manually.

Kari

 

Author: Kari Finn

A former Windows Insider MVP, Kari started in computing in the mid 80’s writing code for VAX / VMS systems. Since then, he’s worked in a variety of IT positions. He specializes in Windows image capture, customization, repair and deployment as well as Hyper-V virtualization. Kari is a proud Team Member at number #1 Windows site TenForums.com.

Leave a Reply