Geeks With Blogs

News



Add to Google

Tim Hibbard CEO for EnGraph software

To connect to a VPN connection inside .net without using any api's do the following

1) Create a VPN connection using the Windows new connection wizard
2) Follow steps 1-4 in this post
3) Create a shortcut to that VPN somewhere, preferably somewhere the client can't find, like All User\Application Data
4) Use Process.Start(the .lnk file) inside your application to shell the VPN connection

When you execute this code, the VPN will connect silently without any prompts to the user

Posted on Wednesday, April 27, 2005 3:36 PM | Back to top


Comments on this post: Connect to VPN in .net

# re: Connect to VPN in .net
Requesting Gravatar...
Is there an easy way to do the setup programmatically?

I think this would be a valuable asset.
Left by Evan Ezewski on May 19, 2005 8:43 AM

# re: Connect to VPN in .net
Requesting Gravatar...
This doesn't seem to work in VB.net
Left by Tony on Jul 13, 2005 12:36 AM

# re: Connect to VPN in .net
Requesting Gravatar...
Tony - Where exactly in the process does it not work?
Left by Tim on Jul 13, 2005 6:56 AM

# re: Connect to VPN in .net
Requesting Gravatar...
I am currently writing a program that does this. The problem I'm having is figuring out how to disconnect from the VPN automatically. All else is working.
Left by Jared on Nov 25, 2005 2:34 PM

# re: Connect to VPN in .net
Requesting Gravatar...
Process.start("RasPhone.exe","-d DUN Test") where 'DUN Test' is the name of the connection. This eliminates the need to create the .lnk file.
Left by Matt Theule on Dec 15, 2005 2:55 PM

# re: Connect to VPN in .net
Requesting Gravatar...
Use the -h option with RasPhone.exe to disconnect.
Left by Daren on Jul 28, 2006 7:50 AM

# re: Connect to VPN in .net
Requesting Gravatar...
Might want to check out the DotRas project on CodePlex. I've spent the last year or so creating a .NET API to control the Windows dialer without using the executables. It should do everything you expect and more.

http://www.codeplex.com/DotRas
Left by Jeff Winn on Mar 25, 2009 10:42 AM

# Wow!
Requesting Gravatar...
costs and ultimate end costs to.LED downlights
Left by led flood light fixtures on Jul 16, 2011 2:13 AM

# Wow!
Requesting Gravatar...
Abaisser les coûts de fabrication et les coûts de fin ultime pour le consommateur par l'amélioration des matériaux utilisés et de trouver des alternatives moins chères aux LED création.[url=http://www.zxlight.fr/]spot encastrable led[/url]
Left by spot encastrable led on Aug 16, 2011 8:51 PM

# re: Connect to VPN in .net
Requesting Gravatar...
You can use sendkey as enter to automate the above.

So something like this.

Process.start("RasPhone.exe","-d DUN Test")
shell("c:\execvpn.wsf")

WSF CODE:

<job id="VBScriptJob" >
<script language="VBScript">
set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 100
WshShell.AppActivate "Connect Pitts"
WScript.Sleep 100
WshShell.SendKeys "~"
WScript.Sleep 500
</script>
</job>




Left by L2G Computing on Sep 05, 2011 3:35 PM

Your comment:
 (will show your gravatar)


Copyright © Tim Hibbard | Powered by: GeeksWithBlogs.net