Re: [請益] 撥接到想要的ip
※ 引述《vernc (cralvin)》之銘言:
: 或那位提供這方面vbs要看那個網頁或那本書
(這篇是被修改內文過的文章XD )
http://moon.cse.yzu.edu.tw/~s922254/applet/redial.vbs
陸陸續續有幾個人問我程式要怎麼改..
因為我原本的程式有幾個地方嚴重寫錯,
所以重改了一份~ 對一般的 user只有開頭三行需要修改
BadIP = "61." ' 這裡指定你不想要的開頭
ShowMessage = True ' 是否要顯示連線過程的訊息
SleepInt = 2000 ' 每次重連的停頓時間(毫秒)
如果 ShowMessage 為 True, 那執行時就會有個黑色畫面顯示每次的 IP
不想看到就改成 False,
一莫一樣的程式內容我貼在下面, 以免 dead-link ||
' *****************************************
' 此段為使用者需要自行修改的部份
' *****************************************
BadIP = "61." ' 這裡指定你不想要的開頭
ShowMessage = True ' 是否要顯示連線過程的訊息
SleepInt = 2000 ' 每次重連的停頓時間(毫秒)
' **************** 結束 ******************
If ShowMessage Then CheckStartMode
Set objWMIService = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\.\root\cimv2")
' 這是例用 Windwos 提供的 WMI 來查網卡的 IP
Set wshShell = WScript.CreateObject ("WSCript.shell")
While True
tag = 0
Set colAdapters = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
' 放網頁資料的 table
For Each objAdapter in colAdapters
If Not IsNull(objAdapter.IPAddress) Then
For i = 0 To UBound(objAdapter.IPAddress)
If InStr(objAdapter.Caption(i),"WAN Miniport") >0 Then
' 你的 ADSL 應該是以 WAN Miniport 表示,
' 如果錯了的話, 你就直接把所有網卡及其對應 IP show 出來看
' 就知道應該要撈哪張卡的 IP了
tag = 1 ' 標記找到你的 ADSl 連線
CurrIP = objAdapter.IPAddress(i)
If ShowMessage Then WScript.Echo "目前的IP: " + CurrIP
If Left( CurrIP, Len(BadIP) ) = BadIP Then
' 若 BadIP 開頭, 利用 rasdial 指令斷線, 停 2000毫秒後
' 重新連線, ADSL 指的是你網頭連線裡的 Sonet連線明稱,
' 請改成你自己的
If ShowMessage Then WScript.Echo "重連中..."
wshshell.run "rasdial /disconnect", 0, True
wshshell.run "rasdial hinet", 0, True
wscript.sleep SleepInt
Else
Wscript.Quit
End if
End if
Next
End If
Next
if tag = 0 Then
WScript.Sleep 5000
' 若這次沒找到你的ADSL連線(可能上次還沒連成功)
' 停5秒再繼續搜
End if
Wend
Sub CheckStartMode
Dim strStartExe
strStartExe = UCase( Mid( wscript.fullname, _
instrRev(wscript.fullname, "\") + 1 ) )
If Not strStartExe = "CSCRIPT.EXE" Then
set oSh = CreateObject("wscript.shell")
oSh.Run "cscript.exe """ & wscript.scriptfullname
wscript.quit
End If
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.139.133.39
→
02/22 20:11, , 1F
02/22 20:11, 1F
→
02/22 20:12, , 2F
02/22 20:12, 2F
→
02/22 21:20, , 3F
02/22 21:20, 3F
→
02/22 21:54, , 4F
02/22 21:54, 4F
→
02/22 21:54, , 5F
02/22 21:54, 5F
→
02/22 22:00, , 6F
02/22 22:00, 6F
→
02/22 22:06, , 7F
02/22 22:06, 7F
→
02/22 22:07, , 8F
02/22 22:07, 8F
→
02/22 22:07, , 9F
02/22 22:07, 9F
→
02/23 14:13, , 10F
02/23 14:13, 10F
→
02/23 15:24, , 11F
02/23 15:24, 11F
→
02/23 15:24, , 12F
02/23 15:24, 12F
→
02/23 15:25, , 13F
02/23 15:25, 13F
→
02/23 15:26, , 14F
02/23 15:26, 14F
→
02/23 15:27, , 15F
02/23 15:27, 15F
→
02/23 15:28, , 16F
02/23 15:28, 16F
推
02/23 18:37, , 17F
02/23 18:37, 17F
→
02/23 19:28, , 18F
02/23 19:28, 18F
→
02/23 19:29, , 19F
02/23 19:29, 19F
→
02/23 19:29, , 20F
02/23 19:29, 20F
※ 編輯: cole945 來自: 220.139.149.83 (03/11 22:37)
討論串 (同標題文章)