Link to home
Start Free TrialLog in
Avatar of Raj Shivaram
Raj ShivaramFlag for India

asked on

Script is looping without an end

Need help with this script. I am trying to get the os, version and patches installed on a server. When i run the script the loop is not stopping and it seems to be running forever until i intervene and stop the script. Please help me in understanding where i am going wrong.

@echo off
setlocal

rem Define output file location
set outputfile=%computername%.csv

rem Overwrite output file and add header line
echo Caption,Version,Node,Description,Type,HotFixID,InstalledBy,InstalledOn>>%outputfile%

rem Gather all data desired
for /f "skip=2 tokens=2 delims=," %%a in ('wmic os get caption /format:csv') do (
  for /f "skip=2 tokens=2 delims=," %%b in ('wmic os get version /format:csv') do (
    for /f "skip=2 tokens=2 delims=," %%c in ('wmic qfe get csname /format:csv') do (
      for /f "skip=2 tokens=2 delims=," %%d in ('wmic qfe get caption /format:csv') do (
        for /f "skip=2 tokens=2 delims=," %%e in ('wmic qfe get description /format:csv') do (
          for /f "skip=2 tokens=2 delims=," %%f in ('wmic qfe get hotfixid /format:csv') do (
            for /f "skip=2 tokens=2 delims=," %%g in ('wmic qfe get installedby /format:csv') do (
              for /f "skip=2 tokens=2 delims=," %%h in ('wmic qfe get installedon /format:csv') do (
              rem Write merged results to output file
                  echo "%%~a","%%~b","%%~c","%%~d","%%~e","%%~f","%%~g","%%~h">>%outputfile%
            )
          )
        )
      )
    )
   )
 )
)
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Raj Shivaram

ASKER

Thank you so much Bill for helping me fix the looping issue and also correcting the script. Also thanks for the tip for adding additional column, I will use it in future.
Avatar of Bill Prew
Bill Prew

Welcome, glad that was helpful.


»bp