I'm trying to use python Subprocess module to enable/disable Ethernet connection from python code. Below is my code in which the first step is looking for the available "Ethernet Connections" and the next step enables/disables the ethernet connection according to the parameter passed in "%interfaces%".
for /f "skip=2 tokens=3*" %%A in ('netsh interface show interface') do set interface=%%B
netsh interface set interface %interface% ENABLED
Now when using in python I couldn't pass the variable, not sure if it's even possible though. Passing only command as below works as expected:
import subprocess
subprocess.call('netsh interface set interface Ethernet10 ENABLED')
I want to do something like:
import subprocess
subprocess.call (set x = 'Ethernet0')
subprocess.call('netsh interface set interface x ENABLED')