以编程方式更改控制面板网络选项以连接到 VPN
可能的重复:
以编程方式更改控制面板网络选项以连接到 VPN
我向我的用户提供 VPN 服务,他们中的很多人抱怨建立新的 VPN 连接并在每次想要连接到我的 VPN 时切换到它很麻烦。
经过一些研究后,我发现有一些方法可以以编程方式执行此操作,例如:
该服务提供了一个程序,可以使用用户名或密码连接到他们的 VPN 服务。我可以自己完成大部分工作,但我真正需要帮助的是他们如何使用程序连接到 VPN,以及如何以编程方式完成此操作。
理想情况下,我需要做的是下面的列表:
- 创建一个临时的新连接以通过 VPN 连接到互联网
- 当用户按“连接”时切换到该连接
- 当用户按“断开连接”时,切换回其主连接连接
- 销毁与 VPN 的临时连接
如果有人知道这是如何完成的并且可能引导我走向正确的方向,我将非常感激。另外,我更喜欢在 C# 中执行此操作,但其他语言参考也会有所帮助。谢谢。
Possible Duplicate:
Programmatically changing Control Panel network options to connect to VPN
I offer a VPN service to my users, and a lot of them complain that it's a hassle to set up a new VPN connection and switch to it every time they want to connect to my VPN.
After doing some research I found there are ways to do this programatically, for example:
This service offers a program to connect to their VPN service with a username or password. I can do most of this stuff myself, but what I really need help with is how they would connect to the VPN with the program, and how they do it programatically.
What I'd ideally need to do is in the list below:
- Create a temporary new connection to connect to the internet through VPN
- Switch to that connection when the user presses "Connect"
- When the user presses "Disconnect", switch back to their main connection
- Destroy the temporary connection to the VPN
If anyone knows how this is done and could possibly steer me in the right direction, I'd be very grateful. Also I'd prefer to do this in C# but other languages references would be helpful as well. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 VPN 连接已经存在,您可以使用各种参数调用 rasdial.exe...
我已经仔细查看了周围,但找不到以编程方式实际创建 VPN 的方法 - 并不是说这是不可能的,但是它看起来并不微不足道。我会手动创建 VPN,然后通过调用 rasdial 进行连接和断开连接。
您可以使用相同的 Proces.Start 方法来调用 rasphone,该方法可用于引导用户设置 VPN... (rasphone -a)
If the VPN connection exists already, you can call rasdial.exe with various parameters...
I've had a good look around and can't see a way to actually create the VPN programatically - not saying it isn't possible, but it doesn't look trivial. I'd create the VPN by hand and then connect and disconnect by calling rasdial.
You can use the same Proces.Start method to call rasphone, which could be used to take a user through setting up a VPN... (rasphone -a)