【发布时间】:2021-02-20 15:17:02
【问题描述】:
脚本启动 openvpn 运行后,我一直在努力继续运行 python 代码。就我而言,在执行os. system('openvpn --config "path_to_config_openvpn_file"') 行后,我无法运行print("hello") 行。有谁可以帮我解决这个问题,您的所有帮助将不胜感激。谢谢
这是脚本:
import os, ctypes, sys, time
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
if is_admin():
os. system('openvpn --config "path_to_the_openvpn_config_file"')
# to stop the process but unable to reach theses lines below
print("hello")
# os. system('taskkill.exe /F /IM openvpn.exe')
else:
# Re-run the program with admin rights
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
【问题讨论】: