01 WScript.Echo arccount & ") Scanning file: " & objArcItem
02 Set objExecObject = objShell.Exec("cmd /c e:\dump.exe /archive "
& objArcItem & " /blocks /checkcrc")
03
04 ' Look for the CRC mismatch text in the STDERR output
05 Do While Not objExecObject.StdErr.AtEndOfStream
06 strText = objExecObject.StdErr.ReadLine()
07 WScript.Echo strText
08 If InStr(strText, "CRC mismatch") > 0 Then
09 WScript.Echo "** FAIL ** CRC mismatch"
10 objFail = 1
11 Exit Do
12 End If
13 Loop
The above snipit works for the one file that gets scanned (variable
definitions omitted in the post). The problem is that when I try scan
a collection (code below), it prints the output from line 1 and then
just hangs. Here is the collection code snipit. Line numbers added for
clarity in pointing out wth I did wrong. :)
01 Dim objFSO: Set objFSO =
CreateObject("Scripting.FileSystemObject")
02 Dim objShell: Set objShell = CreateObject("WScript.Shell")
03 Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\" &
objNetwork.ComputerName & "\root\CIMV2")
04 Dim arccount : arccount = 1
05 Dim objArcItem
06 Dim colArcFiles
07 Dim objExecObject
08
09 ' Query WMI for a list of all ARC files
10 ' on the E drive
11 '
12 Set colArcFiles = objWMIService.ExecQuery("SELECT * FROM
CIM_DataFile WHERE Drive ='e:' AND Extension = 'arc' AND Path LIKE
'%\\[0-2][0-9]\\%' ", "WQL", _
13 wbemFlagReturnImmediately + wbemFlagForwardOnly)
14
15 ' Run the command
16 ' dump.exe /archive {archive name} /blocks /crc
17 ' on every file in the collection colArcFiles
18 '
19 For Each objArcItem In colArcFiles
20 WScript.Echo arccount & ") Scanning file: " & objArcItem.Name
21 Set objExecObject = objShell.Exec("%comspec% /c e:\dump.exe
/archive " & objArcItem.Name & " /blocks /checkcrc")
22
23 ' Look for the CRC mismatch text in the STDERR output
24 Do While Not objExecObject.StdErr.AtEndOfStream
25 strText = objExecObject.StdErr.ReadLine()
26 WScript.Echo strText
27 If InStr(strText, "CRC mismatch") > 0 Then
28 WScript.Echo "** FAIL ** CRC mismatch"
29 objFail = 1
30 Exit Do
31 End If
32 Loop
Any advice would be appreciated.
Kind regards,
/*Raj*/
This is incorrect. Here are a couple of ways to pick up all stream output:
c:\xxx.exe 1>c:\std.txt 2>c:\err.txt
c:\xxx.exe 1>c:\stream.txt 2>&1
You can now scan c:\err.txt (option 1) or c:\stream.txt (option 2).
>This is incorrect. Here are a couple of ways to pick up all stream output:
>
>c:\xxx.exe 1>c:\std.txt 2>c:\err.txt
>c:\xxx.exe 1>c:\stream.txt 2>&1
>
>You can now scan c:\err.txt (option 1) or c:\stream.txt (option 2).
Really? Wow... and I thought I knew DOS. LOL! I learned something new
today. :)
Is there a way to make my WSH program work with the collection as
well?
Thank you for your help.
Kind regards,
/*Raj*/
I would download a copy of script56.chm and scan it for stderr. Lots of
useful stuff in there!