1. 新增新的連線或網路 (名稱叫作 hinet,下面會用到)
2. 將提示名稱、密碼、憑證等打勾取消
3. 用 schtasks 指令排程
schtasks /Create /RU "SYSTEM" /SC ONSTART /TR "C:\Windows\System32\RasPhone.exe -d \"hinet\"" /TN "hinet" /F
———— cut line ————— 2021/03/04
以上作法在 windows 7 會失效
所以改用 vbs (抄來的,再調整)
nickname = "hinet" 'username = "[email protected]" 'password = "xxxxxxxxxxxxxxxxxx" Set WshShell = CreateObject( "WScript.Shell" ) 'RetCode = WshShell.Run( "ping www.hinet.net" , 0, true) 'If RetCode <> 0 Then 'WshShell.Run "rasdial " & nickname & " /DISCONNECT" , 0, true 'WScript.Sleep(3000) 'WshShell.Run "rasdial " & nickname & " " & username & " " & password, 0 WshShell.Run "C:\Windows\System32\RasPhone.exe -d " & nickname, 0 'End If
再把這 vbs 檔 (hinet_reconnect.vbs) 放到排程裡
留言