标题: 如何用批处理或VBS建立一个PPPOE连接
[打印本页]
作者: huanglsh
时间: 2007-6-14 21:27
标题: 如何用批处理或VBS建立一个PPPOE连接
想用批处理或VBS在XP下建立一PPPOE的连接
望高手们帮帮忙
找了个VBS的
Set objShell = CreateObject("Wscript.Shell")
strCommandLine = "Rasphone -a"
objShell.Run(strCommandLine)
set WshShell = CreateObject("WScript.Shell")
WScript.Sleep 200
WshShell.SendKeys "r"
WScript.Sleep 30
WshShell.SendKeys "{ENTER}"
WScript.Sleep 30
WshShell.SendKeys "{ENTER}"
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\宽带连接.lnk")
oShellLink.TargetPath = "%windir%\system32\Rasphone.exe"
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "CTRL+SHIFT+K"
oShellLink.IconLocation = "%windir%\system32\Rasphone.exe, 0"
oShellLink.Description = "宽带连接"
oShellLink.WorkingDirectory = "%windir%\system32\"
oShellLink.Save
以上代码不行.不能直接建立
Last edited by bjsh on 2007-7-31 at 02:53 PM ]
作者: slore
时间: 2007-6-14 21:51
Set WshShell = CreateObject("WScript.Shell")
strCommandLine = "Rasphone -a"
WshShell.Run(strCommandLine)
WScript.Sleep 5000 '把这里要设置的时间长点
WshShell.SendKeys "r"
WScript.Sleep 30
WshShell.SendKeys "{ENTER}"
WScript.Sleep 30
WshShell.SendKeys "{ENTER}"
strDesktop = WshShell.SpecialFolders("Desktop")
Set oShellLink = WshShell.CreateShortcut(strDesktop & "\宽带连接.lnk")
oShellLink.TargetPath = "%windir%\system32\Rasphone.exe"
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "CTRL+SHIFT+K"
oShellLink.IconLocation = "%windir%\system32\Rasphone.exe, 0"
oShellLink.Description = "宽带连接"
oShellLink.WorkingDirectory = "%windir%\system32\"
oShellLink.Save
Set oShellLink = Nothing
Set WshShell = Nothing
作者: huanglsh
时间: 2007-6-14 23:32
谢谢你的回答.这样可以创建军了!!!
改了一下.只是建立个连接.不用在桌面有图标.
然后用rasdial拔号上去
Set WshShell = CreateObject("WScript.Shell")
strCommandLine = "Rasphone -a"
WshShell.Run(strCommandLine)
WScript.Sleep 500 '把这里要设置的时间长点
WshShell.SendKeys "r"
WScript.Sleep 30
WshShell.SendKeys "{ENTER}"
WScript.Sleep 30
WshShell.SendKeys "pppoe"
WScript.Sleep 30
WshShell.SendKeys "{ENTER}"
Set oShellLink = Nothing
Set WshShell = Nothing
Dim wshShell
Set wshShell = CreateObject("Wscript.Shell")
Set EnvVar = wshShell.Environment("PROCESS")
Name=EnvVar.Item("COMPUTERNAME")
strGateway = Array("1.1.1.1")
strComputer="."
Set objWMIService=GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters=objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric) '设置网关
Next
Set WshNetwork = Nothing
dim wsh
set wsh=WScript.CreateObject("WScript.Shell")
wsh.run "Rasdial pppoe 用户名 密码",false,1
WScript.quit
Last edited by huanglsh on 2007-6-14 at 11:57 PM ]