C# - Close OpenVPN Cleanly

廉价感情. 提交于 2019-12-01 01:28:34

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.

StandardInput.Write(ConsoleKey.F4);

Obviously you have to get StandardIn for the process.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!