C# - Close OpenVPN Cleanly

前端 未结 2 1402
慢半拍i
慢半拍i 2021-01-07 14:21

We have written an application that sits in the tray controlling OpenVPN as an extension to a bigger application.

If you run openvpn.exe on command line, you can pre

相关标签:
2条回答
  • 2021-01-07 15:04
    StandardInput.Write(ConsoleKey.F4);
    

    Obviously you have to get StandardIn for the process.

    0 讨论(0)
  • 2021-01-07 15:08

    If I run OpenVPN as the following:

    "openvpn.exe --config PathToMyConfig.ovpn --service MyEventName 0"
    

    Then the following C# code causes OpenVPN to exit cleanly:

    EventWaitHandle resetEvent = EventWaitHandle.OpenExisting("MyEventName");
    
    resetEvent.Set();
    

    Props to consultutah, his comments helped quite a bit.

    0 讨论(0)
提交回复
热议问题