在windos CMD中我总是使用:
route delete 172.0.0.0 mask 255.0.0.0 172.0.0.0
route add 172.0.0.0 mask 255.0.0.0 172.0.0.0
和
netsh 192.168.255.0 255.255.255.0
改变我的ipconfig。
我想在python中执行此操作,是否有pip api或import我可以使用?任何示例代码?
我之前试过这个python get UAC:
import subprocess
subprocess.run('route delete 172.0.0.0 mask 255.0.0.0 172.0.0.0')
但返回:“请求的操作需要提升。”
我不想用这个:
import ctypes, sys
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
if is_admin():
# Code of your program here
else:
# Re-run the program with admin rights
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
因为我正在尝试 pyqt5 运行 ipconfig ,
这个python get UAC将重新打开许多对话框窗口,
最后会崩溃。