在XP中通过命令行连接/断开VPN客户端

在XP Pro工作站中,是否有办法启动本地Windows VPN客户端,并从命令行打开/closures连接,以便可以在batch file中编写脚本?

是的,如果VPN连接被称为“我的VPN”,那么:

rasdial "My VPN" 

将拨打连接。 如果它连接失败,它会帮助它将错误级别设置为RAS错误代码,所以脚本可以检测到连接失败。 如果您需要提供用户名和密码,而不是使用保存的凭证,请使用:

 rasdial "My VPN" username password 

要断开连接,请使用:

 rasdial "My VPN" /disconnect 

JR

在Windows 7下工作的另一种select(不确定XP)是:

 rasphone -d "My VPN" 

这将popup“拨号”对话框,就像双击连接一样。 如果您保存了用户名和密码,则会自动拨号。

rasdial没有为我工作(在Windows 7上):

 Verifying username and password... Remote Access error 691 - The remote connection was denied because the user name and password combination you provided is not recognized, or the selected authen tication protocol is not permitted on the remote access server. 

如果您在Windows 7下添加空string,它将使用caching的凭据:rasdial“My VPN”“”“”(这是两对双引号之间没有任何内容)

运行命令行: Control ncpa.cpl

在这里输入图像描述

networking连接控制

网络连接控制

在第一次运行中,编辑我的VPN设置

在这里输入图像描述

设置后,编辑我的VPN设置

在这里输入图像描述

保存凭据

在这里输入图像描述

目标VPN主机设置

在这里输入图像描述

无声的VPN设置

在这里输入图像描述

VPNnetworking

在这里输入图像描述

VPN TCP高级

在这里输入图像描述

VPN网关

在这里输入图像描述

高级networking连接

在这里输入图像描述

设置优先接口

在这里输入图像描述

设置优先接口应用

在这里输入图像描述

设置优先networking提供商

在这里输入图像描述

脚本Silent-dial.cmd

 :: - comment in cmd) - REM alternative :: disabled command output @echo off :: 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 @rasphone -h "My VPN" :: END Silent-dial.cmd 

使用powershell或WSH。

我还没有看到客户端的命令行scheme。 但是,这并不意味着它不能在脚本中自动执行。 这是一个两步走的方法,

  • 为您的VPN用户创buildVPN的快捷方式链接
    • 保持它configuration用户名和密码
  • 使用AutoIt脚本只,
    • 启动快捷方式,和
    • 在VPNlogin窗口上按下ENTER(这是用户在configuration完成后所做的)

如果我记得正确,按下input窗口的代码是简单的,

 Send ("{ENTER}") 

看看发送命令。

您可以在您的某个pipe理机器上设置AutoIt,获取脚本工作,制作并执行它,并将其交给用户。 然后它可以作为可执行文件从命令行启动。