中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-05 00:59
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 如何用批处理或VBS建立一个PPPOE连接 查看 929 回复 2
楼 主 如何用批处理或VBS建立一个PPPOE连接 发表于 2007-06-14 21:27 ·  中国 广东 佛山 禅城区 电信
新手上路
积分 15
发帖 6
注册 2007-06-10 17:25
19年会员
UID 90896
性别 男
状态 离线
想用批处理或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 ]
2 发表于 2007-06-14 21:51 ·  中国 陕西 西安 电信
铂金会员
★★★★
积分 5,212
发帖 2,478
注册 2007-02-08 23:39
19年会员
UID 79003
性别 男
状态 离线
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
3 发表于 2007-06-14 23:32 ·  中国 广东 佛山 禅城区 电信
新手上路
积分 15
发帖 6
注册 2007-06-10 17:25
19年会员
UID 90896
性别 男
状态 离线
谢谢你的回答.这样可以创建军了!!!

改了一下.只是建立个连接.不用在桌面有图标.
然后用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 ]
论坛跳转: