In an XP Pro workstation, is there a way to start the native Windows VPN client and open/close a connection from the command line so it can be scripted in a batch file?
|
Yes, if the VPN connection is called "My VPN" then:
will dial the connection. Helpfully it sets errorlevel to the RAS error code if it fails to connect, so your script can detect a connection failure. If you need to supply a username and password instead of using the saved credentials use:
To disconnect a connection use:
JR |
|||||||||
|
|
:: run command-line: Control ncpa.cpl
:: Network Connections control
:: first run edit My VPN Settings
:: after setup edit My VPN Settings
:: save cred
:: destination VPN host settings
:: silent VPN up settings!
:: VPN networking
:: VPN TCP advanced
:: VPN GW
:: Advanced network connection
:: Set priority interface
:: Set priority interface apply
:: Set priority network provider
:: Silent-dial.cmd :: - comment in cmd) - REM alternative :: disabled command output
:: Silent dial "My VPN" @rasphone -d "My VPN" :: wait 10 sec W2K3 server test ::@SET waitsec=10 ::@choice /T %waitsec% /N /D y /M "wait %waitsec% sec" :: wait 10 sec - alternative - XP .. 7 @ping 127.0.0.1 -n 10 > NUL :: ************************ :: get path :: set route table :: run application :: ************************ @ping 127.0.0.1 -n 10 > NUL :: silent close "My VPN" connection
:: END Silent-dial.cmd Use powershell or WSH ... |
||||
|
|
|
I have not seen a command line scheme for the client yet. But, that does not mean it cannot be automated in scripts. Here is a two step approach,
If I recollect correctly, the code for pressing enter on a window is simply,
Look at the Send command. You can setup AutoIt on one of your administration machines, get the script working, make and executable for it, and give it to the users. It can then be launched from command line as an executable. |
||||
|
|
|
An alternative that works under Windows 7 (not sure about XP) is:
This brings up the "dialling" dialog, same as if you double-click on the connection. If you have the username and password saved it automatically dials.
|
|||
|
|













