Jump to content

Automate which network Adapter is being shared?

Cheesus182

Hey guys,

 

would anyone be able to write a short script to automatically change which Network Adapter is being shared?

I currently have to connect my Xbox through my laptop and a VPN since my Uni network is ridiculously restrictive. For games I mostly need the VPN enabled and then share the Tap 9 adapter through my Ethernet port. However, when I want to use Netflix or other streaming services on my Xbox, I have to disable the VPN and share the standard WiFi connection. 
Is there anyway to automate this process?

I.e. When the VPN is connected, it automatically shares the Tap 9 Adapter, when the VPN is disconnected it goes back to sharing the WiFi Adapter.

 

Would be amazing if anyone had any idea on how to do this. I have 0 coding knowledge of any kind of unfortunately can't help my self here.

 

Thanks guys!

Link to comment
Share on other sites

Link to post
Share on other sites

You can enable and disable network adapters using the command prompt.

 

netsh interface set interface <adapter name> disable

 

or

 

netsh interface set interface <adapter name> enable

 

Just stick the relevant commands into 2 batch files and then double click the relevant one to change the sate. 

 

 

You can also do it via powershell:

 

Disable-NetAdapter -Name <adapter name> -Confirm:$false

 

or

 

Enable-NetAdapter -Name <adapter name> -Confirm:$false

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, FlappyBoobs said:

You can enable and disable network adapters using the command prompt.

 

netsh interface set interface <adapter name> disable

 

or

 

netsh interface set interface <adapter name> enable

 

Just stick the relevant commands into 2 batch files and then double click the relevant one to change the sate. 

 

 

You can also do it via powershell:

 

Disable-NetAdapter -Name <adapter name> -Confirm:$false

 

or

 

Enable-NetAdapter -Name <adapter name> -Confirm:$false

 

 

 

Wouldn't this simply enable/disable the adapters though? The WiFi adapter is always enabled and the Tap 9 is only enabled when the VPN is connected.

The WiFi adapter shouldn't ever be disabled and the Tap 9 should only be enabled when the VPN is active. Its more about which adapter shares its connection. I.e. By default the WiFi adapter is being shared, when the VPN is connected, the Tap 9 adapter needs to be shared.

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Cheesus182 said:

 

Wouldn't this simply enable/disable the adapters though? The WiFi adapter is always enabled and the Tap 9 is only enabled when the VPN is connected.

The WiFi adapter shouldn't ever be disabled and the Tap 9 should only be enabled when the VPN is active. Its more about which adapter shares its connection. I.e. By default the WiFi adapter is being shared, when the VPN is connected, the Tap 9 adapter needs to be shared.

Yes that's what it would do. If you disable the tap 9 adapter windows should stop the share. Then all you need to do is disable the VPN. It should be easy enough to work your way back to getting the VPN back up again. 

 

I've not tested this and give no guarantees but hopefully you'll be able to start the process there and learn something. Troubleshooting is a good skill to have. 

 

If you just want the straight answer or a premade script then just Google it. 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×