我在寫一個VBScript,PINGS服務器和循環。VBscript Ping循環腳本問題
如果"Request Time Out"
大於2,則應該執行Wscript.echo"cannot connect to server"
。
我的代碼如下。似乎沒有任何語法錯誤,但wscript.echo也未被執行!誰能幫我解決這個問題嗎?
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Rem Sends email alert
Set wshShell = WScript.CreateObject("WScript.Shell")
strComputer = "."
strCommand = "ping SER1"
strResults=""
while InStr(1,StrResults,"Request timed out")>2
Set objExecObject = objShell.Exec(strCommand)
Do While Not objExecObject.StdOut.AtEndOfStream
WScript.echo "Cannot Connect to Server"
strResults = objExecObject.StdOut.ReadAll()
Loop
wend
'雖然條件.. Wend'循環執行一系列的語句,只要給定的條件是'真'。由於'strResults =「」'它不能包含任何子字符串,所以'雖然.. Wend'條件總是結果爲'False' – JosefZ 2014-10-07 22:37:16