Wednesday, July 16, 2008 9:58 PMI'm making an application that will connect to a Microsoft VPN, wait for it to finish, then start up a VNC connection to a remote PC. Is there a way to connect to the VPN in code. I know it's possible for Cisco by running a command in command prompt, but can Microsoft do a similar feat?
Any thoughts would be greatly appreciated.
Thursday, July 17, 2008 12:20 PMI think what you're asking is after you create the connection like this:
How do you call it programmactically?
I don't know the answer to this, but.... all programs start off being called by a command interpreter.
In windows quite often there are file associations with the objects' file extension for example the most famous is .exe.
When the OS sees certain file extensions it just knows what to do.
So, what I'd try if I were you would be to determine the file extension type of the connection object.
Then start a Process from C# that just calls the connection object.
The OS should take care of the rest.
Thursday, July 17, 2008 4:18 PMYup. That's my question all right.
As it turns out, the VPN information is scattered in the registry and in some bizarre XML-like format (it doesn't appear to be XML exactly) deep in the depths of Windows - one of the areas with really long file names. I found it by doing a scan of System32 using ExamDiff Pro. Of course, everything's encoded, and I doubt Microsoft would tell me how to decode it - I would assume that would be explorer.exe's job. However, I can make a shortcut to it somewhere and reference that, but it doesn't come back and tell me it's done. And just in case, sleeping or pausing a thread for a certain amount of time is a really dirty way of doing it.
I already know how to run a process: System.Diagnostics.Process.Start(<file name>, <args>).
I'm beginning to seriously doubt the capabilities of the Microsoft VPN, and am considering making everyone switch to Cisco. (But that wouldn't be good, now would it...)
Just a thought, is there a way to intercept commands that windows is doing? I've started working with linux due to XP not being sold anymore and Vista being a power hog (besides that, linux is free), and I'm pretty sure there's a way to see the background commands inside it.
Eventually, I will be reprogramming for linux, but that may be down the road after we run out of the XP machine stockpile.
Thanks for the response!
- Edited by Raptor354 Thursday, July 17, 2008 4:19 PM Fixed several grammerical errors
Thursday, July 17, 2008 5:17 PMIn talking to a fellow programmer, he said that there was a DLL somewhere that allowed you to connect to a VPN, among other things.
If anyone knows what DLL that might be, I'd be interested in any ideas.
Thursday, July 17, 2008 10:23 PMhttp://geekswithblogs.net/thibbard/articles/CSharpCodeToMaintainVPNConnectionProgramatically.aspx
Friday, July 18, 2008 3:07 PMAwesome! That's exactly what I needed.
Tuesday, July 22, 2008 8:50 PMFor all of you who are looking to do a similar feat to what I did, the command is as follows:
rasdial <vpn_name> <vpn_username> <vpn_password>
rasdial <vpn_name> /d
Thus, in usable terms, my line would look like this:
System.Diagnostics.Process.Start("rasdial.exe", "My_VPN My_Username My_Password");
To disconnect from the VPN, simply use this line:
System.Diagnostics.Process.Start("rasdial.exe", "My_VPN /d");
Wednesday, March 25, 2009 3:21 PMThe dialer can be controlled in Windows using the RasDialer component in the DotRas project on CodePlex.
There's a documentation available for connecting and disconnecting entries there if you need help.
- Proposed As Answer by Jeff Winn Wednesday, March 25, 2009 3:21 PM
Thursday, June 11, 2009 9:14 PMCan we connect to CISCO VPN Client using DotRas?
Friday, February 05, 2010 2:44 AM
Generally speaking no it won't support third party connections. However, if you can dial the connection from Windows without using a 3rd party tool (aka, the Cisco VPN client) then DotRas can handle it as well.
Tuesday, July 24, 2012 5:52 PMfour years later, this post is still beneficial. i had never worked with "rasdial" in command prompt. nice work.