Dual Core
Dual Core

Reputation: 99

How to executes cmd command using Python on Win 7 with admin

in python, i want to executes cmd command:

os.system("netsh interface set interface \"Local Area Connection\" disable")

to disconnect internet network. But, with my account, it report, interface name not register router. I think that, i need to executes os.system as admin. But i don't know how to use it as admin! So, can you help me! Thank.

Upvotes: 6

Views: 19254

Answers (1)

user689383
user689383

Reputation:

To run command as admin on Windows, ou can use Windows runas command (I don't have access to a Windows machine right now, but perhaps..);

import subprocess
subprocess.call(['runas', '/user:Administrator', 'Your command'])

Upvotes: 2

Related Questions