Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ReadLine in Do Loop not working correctly 3

Status
Not open for further replies.

Dontbyteme

IS-IT--Management
May 14, 2014
8
US
I'm having trouble getting this script to read past the first line of txt in my txt file. I've put my .ReadLine in a Do Until Loop, but it still only reads the first line. I have a total of 4 computer names in my ComputerListTest.txt file. After I get it working correctly, I'll add the rest of our computers to the list. Any idea why it won't read the rest of the txt in my txt file?

Code:
'File name for remote system results
        'strComputer= "computerInfo2"
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objFile = objFSO.CreateTextFile("ComputerInfoList.txt", True)
        Set objComputerlist = objFSO.OpenTextFile("C:\Users\username.adm\Documents\PatchScriptTest\ComputerListTest.txt", 1)

        On Error Resume Next
'Query network PC's for information
        Do Until objComputerlist.AtEndOfStream
                strComputer = objComputerlist.ReadLine
                Set objGroup = GetObject("" & strComputer)

                For Each objMember In objGroup.Members
                        Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
                        objFile.WriteLine "Today is:" & FormatDateTime(Now,0)
                        objFile.WriteLine "Computer:" & strComputer
                        objFile.WriteLine "Serial Number: " & objSMBIOS.SerialNumber

'Find serial number
        Set colSMBIOS = wmi.ExecQuery("Select * from Win32_SystemEnclosure")
        For Each objSMBIOS in colSMBIOS
        objFile.WriteLine "Serial Number: " & objSMBIOS.SerialNumber
        Next

'Find MAC & IP
        Set IPConfigSet = wmi.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=True")
        For Each IPConfig in IPConfigSet
                objFile.WriteLine "IP Address:   " & Join(IPConfig.IPAddress,"|")
                objFile.WriteLine "MAC Address:  " & IPConfig.MACAddress
        Next

'Query system to installed KB's
        oTS.WriteLine "INSTALLED HOTFIXES"
        Set colItems = wmi.ExecQuery("Select * from Win32_QuickFixEngineering")
        For Each objItem in colItems
                objFile.WriteLine "" & objItem.HotFixID
        Next

'Print out list of installed software
        objFile.WriteLine
        objFile.WriteLine "INSTALLED SOFTWARE"
        objFile.WriteLine

'Query system for installed software
        Set colItems = objWMIService.ExecQuery("Select * from Win32_Product")
        For Each objItem in colItems
                objFile.WriteLine "Caption: "     & objItem.Caption
                objFile.WriteLine "Version: "     & objItem.Version
                objFile.WriteLine "Description: " & objItem.Description
                objFile.WriteLine 
        Next

                Next
        Exit Do
        Loop
 
Why this statemeent ?
Exit Do

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Was that done to make sure the DO loop only ran once, as I see it would never loop. The Until would get check before the next pass, but the exit would prevent that from ever happening.

[yinyang] Tranpkp [pc2]
 
You guys are awesome!!! Thanks. I'm sorry I didn't catch your hint PHV, after strongm told me that it was a hint, then I tried deleting the Exit Do and it worked wonderfully. Thank you, thank you so much!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top