1
我想製作一個腳本,它會ping一個IP地址,直到它收到響應。當它發生時,它會啓動另一個名爲「sound.vbs」的腳本。我有兩個問題:Pinging和啓動程序
- 我不要 希望cmd窗口在執行ping命令時彈出。
- 即使ping失敗,腳本也會關閉,而不是等待一段時間並重試ping。
代碼:
Dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")
Dim target 'define target ip
Dim result 'define ping result
target= "193.105.173.130" 'Archeage EU server IP (possibly Shatigon)
result = "Request timed out" 'Initial result
Set shell = WScript.CreateObject("WScript.Shell") 'create WScript shell
Set shellexec = shell.Exec("ping " & target) 'setting up the ping
Dim count
count = 1
Do
result = LCase(shellexec.StdOut.ReadAll)
If InStr(result , "reply from") Then
objShell.Run "sound.vbs"
Set objShell = Nothing
count = count + 1
Else
WScript.Sleep 4000
End If
Loop until count < 2
如何解決上市問題?
啓發思考[這個例子](http://stackoverflow.com/a/32302212/2165759)隱藏控制檯窗口並檢索輸出。 – omegastripes
感謝您的幫助,但在等待回覆時,使用Java搜索shell執行,似乎我幾乎完成了,哈哈。 – Justin