![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | VB script just keeps looping and does not excute the code Here is the code : On Error Resume Next Const ForReading = 1 'Create FSO Set objFSO = CreateObject("Scripting.FileSystemObject") 'Read Text File Set objFile = objFSO.OpenTextFile("U:\Scripts\PST\4fl_segment.txt", ForReading) Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strcomputer & "\root\cimv2") Do Until objFile.AtEndOfStream strcomputer = objFile.ReadLine '**************************************** Start Ping ******************************************* Set colItems = objWMIService.ExecQuery _ ("Select * from Win32_PingStatus " & _ "Where Address ='" & strcomputer & "'") 'WScript.Echo strcomputer & " Reply Received" For Each objItem In colItems If objItem.StatusCode = 0 Then '*********************************************************************************************** 'get ost files Set colFiles = objWMIService.ExecQuery _ ("Select Name from CIM_DataFile" _ & " where Drive='C:' and Extension='OST'") 'WScript.Echo "# of files found: " & colFiles.Count For Each objFile in colFiles Wscript.Echo strcomputer Wscript.Echo objFile.Name Next Else Wscript.Echo strcomputer & " No Reply" End If Next Loop objFile.Close It reads the text file but does not excute the 'get ost files. It does work when I use my local machine. Please help me |
My System Specs![]() |
| | #2 (permalink) |
| | Re: VB script just keeps looping and does not excute the code "freddy" <freddy@xxxxxx> wrote in message news:80F6CC5B-8FFA-4343-A159-E827347190C3@xxxxxx Quote: > Here is the code : > > On Error Resume Next > Const ForReading = 1 > 'Create FSO > Set objFSO = CreateObject("Scripting.FileSystemObject") > 'Read Text File > Set objFile = objFSO.OpenTextFile("U:\Scripts\PST\4fl_segment.txt", > ForReading) > Set objWMIService = GetObject("winmgmts:" _ > & "{impersonationLevel=impersonate}!\\" & strcomputer & "\root\cimv2") > Do Until objFile.AtEndOfStream > strcomputer = objFile.ReadLine > > '**************************************** Start Ping > ******************************************* > Set colItems = objWMIService.ExecQuery _ > ("Select * from Win32_PingStatus " & _ > "Where Address ='" & strcomputer & "'") > 'WScript.Echo strcomputer & " Reply Received" > For Each objItem In colItems > If objItem.StatusCode = 0 Then > '*********************************************************************************************** > 'get ost files > Set colFiles = objWMIService.ExecQuery _ > ("Select Name from CIM_DataFile" _ > & " where Drive='C:' and Extension='OST'") > 'WScript.Echo "# of files found: " & colFiles.Count > For Each objFile in colFiles > Wscript.Echo strcomputer > Wscript.Echo objFile.Name > Next > Else > Wscript.Echo strcomputer & " No Reply" > End If > Next > Loop > objFile.Close > > It reads the text file but does not excute the 'get ost files. It does > work > when I use my local machine. Please help me an error message to help troubleshooting. A quick glance show that the code redefines objFile. In the loop where you read lines of objFile, the object reference is redefined to be one of the files on a computer. Maybe you can just use a different variable name. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Script-based code sample library (HTA) | VB Script | |||
| cannot excute command to open message | Vista mail | |||
| Is there a shorter code to perform this ps1 script ? | PowerShell | |||
| MSBuild script for Getlatest cource code | .NET General | |||
| Help looping a script | PowerShell | |||