os.system is a very old choice and is not recommended.
Instead, you should consider subprocess.call() or subprocess.Popen() .
Here's how to use them:
If you do not care about the exit, then:
import subprocess ... subprocess.call('netsh interface ipv4 set interface ""Wireless Network" metric=1', shell=True)
If you care about the exit, then:
netshcmd=subprocess.Popen('netsh interface ipv4 set interface ""Wireless Network" metric=1', shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE ) output, errors = netshcmd.communicate() if errors: print "WARNING: ", errors else: print "SUCCESS ", output
Oz123
source share