Jump to content

Launch VPN in XP Network Connection (or from .LNK file)?


Recommended Posts

Here's a mystery I can't solve despite some searching in the forums. I have a VPN connection set up in Windows XP Network Connections. XP lets you drag this connection to a desktop shortcut, and I have a hotkey that launches the shortcut (which is a .LNK file, by the way). But I can't figure out how to launch either the desktop shortcut or the connection itself from a script. The Run() command doesn't seem to work for a .LNK file, and I don't find a simple syntax for launching the connection icon (unless I'm missing something obvious).

Can anyone suggest a simple way to do this? Launching the desktop shortcut would of course be the easiest way.

Thanks for any help.

Link to comment
Share on other sites

You can use a built in program on WindowsXP called Rasdial.exe

From a command prompt type "rasdial.exe /?" and it will show all of the options.

I use Rasdial.exe "My Connection" myusername mypassword

And Rasdial.exe "My Connection" /disconnect

You need to use quotes on the connection name/username/password entries if they have spaces in their names

there are other options you can use such as including a domain name and phone number as well

Here's an example using Autoit:

RunWait("Rasdial.exe myvpn myusername mypassword");Connects to the specified dial-up entry
MsgBox(0, "Connected", "You have successfully connected")
RunWait("Rasdial.exe myvpn /disconnect");disconnects the specified dial-up entry
MsgBox(0, "Disconnected", "You are now disconnected")

EDIT: This command brings up a black dos screen when connecting. You may want to specify @SW_HIDE in the runwait commandline if you don't want to see this:

RunWait("Rasdial.exe myvpn myusername mypassword","", @SW_HIDE)

EDIT #2: This works for any dial-up connection in your network connections window whether it be a modem connection or a VPN connection.

Edited by sykes

We have enough youth. How about a fountain of SMART?

Link to comment
Share on other sites

heres a little tester that works with shortcuts... i know it works with shortcuts leading to exe files

... but .... maybe give it a try

#include "GUIConstants.au3"
Dim $tim = 500, $runner = ""

$Menu = GUICreate("My menu", 300, 200, -1, -1, -1, $WS_EX_ACCEPTFILES)

$Create = GUICtrlCreateLabel( "Drop a  *link*  or an  *exe*  in the box", 10, 10, 250, 20)

$Prog_1A = GUICtrlCreateInput("", 10, 30, 280, 20)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)

$Btn1 = GUICtrlCreateButton("TEST", 110, 110, 70, 30) 

GUISetState()

While 1
    
    $Msg = GUIGetMsg()
    
    If $Msg = $Btn1 Then
        While 2
        ;SoundPlay($Sound_clk)
            GUICtrlSetData($Create, "***** Reading Program ***** ")
            Sleep($tim)
            $Prog_1 = GUICtrlRead($Prog_1A)
            $result = StringInStr($Prog_1, ".lnk")
            If $result >= 5 Then
                $details = FileGetShortcut($Prog_1)
                $Runner = $details[0]
                GUICtrlSetData($Create, "*.lnk* Program Launch is accepted")
                Sleep($tim)
                ExitLoop
            EndIf
            $result2 = StringInStr($Prog_1, ".exe")
            If $result2 >= 5 Then
                $Runner = $Prog_1
                GUICtrlSetData($Create, "*.exe* Program Launch is accepted")
                Sleep($tim)
                ExitLoop
            EndIf
            GUICtrlSetData($Create, "*NOTE* Program Launch was *NOT* accepted")
            Sleep(3000)
            GUICtrlSetData($Create, "Please DROP a Short-cut (picture) in the box")
        WEnd
    EndIf

    If $Runner <> "" Then
        MsgBox(0,"", $Runner)
        Run($Runner)
        $Runner = ""
    EndIf
    
    If $Msg = $GUI_EVENT_CLOSE then Exit
WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

Here's a mystery I can't solve despite some searching in the forums. I have a VPN connection set up in Windows XP Network Connections. XP lets you drag this connection to a desktop shortcut, and I have a hotkey that launches the shortcut (which is a .LNK file, by the way). But I can't figure out how to launch either the desktop shortcut or the connection itself from a script. The Run() command doesn't seem to work for a .LNK file, and I don't find a simple syntax for launching the connection icon (unless I'm missing something obvious).

Can anyone suggest a simple way to do this? Launching the desktop shortcut would of course be the easiest way.

Thanks for any help.

maybe i'm over simplifying, but if you're able to set a hotkey for the launch, why not just Send() the hotkey?
Link to comment
Share on other sites

...why not just Send() the hotkey?

'cuz that might require 2 lines of code:

WinActivate("Program Manager")

Send("^!n")

Those 2 lines of code work for me on XP for an OS "Shortcut key" of n

...but all of this could be done in a one line Run statement:

http://www.autoitscript.com/forum/index.php?showtopic=4759

And then there is SlimShady's version of ezzetabi's ShellExecute at the bottom of this post:

http://www.autoitscript.com/forum/index.php?showtopic=5383

later...

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...