Essentially, with the help of a generous colleague, we built this script to do the following:
1) Over an internal corporate network we do a machine bios search (DNS search essentially) using a list we created from, say c:\systemlist.txt
2) We search these computers from #1 in a location on the remote machines in \c$\syslevel
3) The filename we're looking for, as an example, is test*.*
4) We then dump the results of whether it finds this test*.* successfully, or doesn't find it, or the network times out to a file c:\RESULTS.txt
The problem is this:
As the vbscript is going through the list some machines it won't obviously find on the network due to lag or the remote machine is not turned on.
How do I create a timeout that I can set for, say, 5-15seconds or whatever so that between scans of the computers in #1 it will only, say, scan the machine for 5seconds then just go to the next one in the list if no result was found? Remember, this is looking at the remote PCs name's via a DNS lookup and out network guys cannot change this so if I can do it artificially within the script so it doesn't have to wait up to 1-2mins to not find a machine then it would drastically cut down my query times.
My code:
Thanks Vista community. Your help would be MOST appreciated here!Code:on error resume next Const ForReading = 1 Const ForWriting = 2 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile ("c:\systemlist.txt", ForReading) Wscript.Timeout = 5 Wscript.echo objtextfile ' ************************************************************* ' create the input array strText = objTextFile.ReadAll objTextFile.Close arrComputers = Split(strText,vbcrlf) ' ************************************************************* Dim objFolder, objFile, TS Dim strDirectory, strWildCard, strPattern Dim strLog, blnFound, i Dim objRegExpr 'Create an instance of the regexp object Set objRegExpr = CreateObject("VBScript.RegExp") strWildCard = "test*.*" 'Update the wildcard string to define a valid regular expression strPattern = Replace(strWildCard, ".", "\.") strPattern = Replace(strPattern, "*", ".*") strPattern = "^" & strPattern & "$" strPattern = Replace(strPattern, ".*$", ".+$") objRegExpr.Pattern = strPattern objRegExpr.Global = True objRegExpr.IgnoreCase = True 'Set where you will log your findings strLog = "c:\RESULTS.txt" Set TS = objFSO.OpenTextFile(strLog,ForWriting,true) For i = 0 To UBound(arrComputers) 'Get the directory you are searching strDirectory = "\\" & arrComputers(i) & "\c$\syslevel\" 'Set your found flag blnFound = False 'Check that that the directory exists. This shouldn't take 'long to retrun false if the machine can't be reached. If objFSO.FolderExists(strDirectory) Then 'Get the current folder Set objFolder = objFSO.GetFolder(strDirectory) 'Loop through all the files in the folder For Each objFile In objFolder.Files 'Check if the file matches the wildcard search If objRegExpr.Test(objFile.Name) Then 'Add file to log if found TS.WriteLine(arrComputers(i) & vbTab & objFile.Name) blnFound = True End If Next Else 'Note in the log if the machine couldn't be reached TS.WriteLine(arrComputers(i) & " **Network Path could not be resolved**") blnFound = True End If 'Add note if the file wasn't found If not blnFound Then TS.WriteLine(arrComputers(i) & vbTab & strWildCard & " not found") End if 'Add an extra line to seperate the machines 'TS.WriteLine("") Next TS.Close Set TS = Nothing Set objRegExpr = Nothing MsgBox "QUERY COMPLETED!"


There has to be another method inside vbscript to query the list for a selectable amount of time before it considers the result a TIMEOUT then proceed to next machine in the list? 