有人可以帮助新手吗?参考资料位于:Request UAC elevation from within a Python script?
这很棒,但是不知所措:)我正在运行一个命令,以启用它发现已禁用的所有NIC ...它返回了需要提升权限的错误。
for interface in c.Win32_NetworkAdapterConfiguration(IPEnabled=0):
if "Debug" not in interface.Description:
print(interface)
for nic in c.Win32_NetworkAdapter(NetEnabled=False):
enableNic= nic.NetConnectionID
print("The nic for enablement is ", enableNic)
> subprocess.Popen('netsh interface set interface %s admin=enable' % (enableNic))
> print('netsh interface set interface="%s" admin=enabled' % (enableNic))
> os.system('netsh interface show interface')
我得到的是:
启用的网卡是Ethernet1 netsh interface set interface =“ Ethernet1” admin = enabled
请求的操作需要提升(以管理员身份运行)。
如何将其他帖子中的答案整合到其中,以使我能够启用NIC?
感谢:)