C# Windows Service that connects to network through VPN

二次信任 提交于 2020-03-05 01:34:58

问题


I have a Windows Service that must connect, via VPN, to the network in order to send emails. What I need to do (when I start the service) is check whether the VPN connection exists, if not create it, and then connect to the network.

I was looking at DotRAS which looks ideal for doing all the work, however, it doesn't seem to provide a method for creating a new VPN connection.

So my question is, is there a way in which I can programmatically create a VPN connection?


回答1:


Use a scriptable VPN client, and run it using Process.Start("path-to-your-script").

Depending on which client you use, you have different possibilities regarding monitoring the status of the VPN connection.

Here is an article where the Windows rasphone client is used in such a way.




回答2:


My mistake, turns out DotRAS does have a method for creating new VPN connections :)



来源:https://stackoverflow.com/questions/1571031/c-sharp-windows-service-that-connects-to-network-through-vpn

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