【问题标题】:How to keep running python script after running openvpn GUI运行openvpn GUI后如何继续运行python脚本
【发布时间】: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)

【问题讨论】:

    标签: python openvpn


    【解决方案1】:

    尝试使用start

    os.system('start "open vpn" /D openvpn.exe --config "path_to_the_openvpn_config_file"')
    

    【讨论】:

      【解决方案2】:

      我为这篇文章找到了自己的解决方案。我所做的是按照官网 OpenVPN https://openvpn.net/vpn-server-resources/use-openvpn-connect-v3-on-windows-in-service-daemon-mode/?fbclid=IwAR3o4Dv9les4bKhWqkfahG9orBHeQvmyrIV7yMwy1BduduNHKUz3ukZJ7gg 中的说明以守护程序模式运行流

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-02-08
        • 2013-12-08
        • 2011-08-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多