在XP Pro工作站中,是否有一种方法可以启动本机Windows客户端并从命令行打开/关闭连接,以便可以在批处理文件中编写脚本?
发布于 2009-06-21 22:46:26
是的,如果VPN连接被称为"My“,那么:
rasdial "My VPN"
会拨通连接。有益的是,如果RAS错误代码连接失败,它会将错误级别设置为RAS错误代码,这样脚本就可以检测到连接失败。如果需要提供用户名和密码,而不是使用保存的凭据,请使用:
rasdial "My VPN" username password
若要断开连接,请使用:
rasdial "My VPN" /disconnect
JR
发布于 2013-03-27 22:32:09
在Windows 7下工作的另一种选择(对XP不确定)是:
rasphone -d "My VPN"
这会弹出“拨号”对话框,就像双击连接一样。如果你有用户名和密码,保存它自动拨号。
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下添加空字符串,它可以处理缓存的凭据:ras拨号"My“(这是两对双引号,两者之间没有任何内容)
发布于 2012-11-22 10:08:11
运行命令行:Control ncpa.cpl
网络连接控制
在第一次运行中,编辑我的VPN设置
安装完毕后,编辑我的VPN设置
保存凭据
目标VPN主机设置
无声VPN启动设置
VPN网络
VPN TCP高级
VPN网关
高级网络连接
设置优先级接口
设置优先级接口应用
设置优先级网络提供者
脚本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。
https://serverfault.com/questions/29513
复制相似问题