'*********************************************************************************'Script to remotely inventory installed services from a list of machines from a' text file, put the services into an Excel workbook, and then save the' workbook to the desktop.' Created by: Brian Bohanon' Created: 6/17/2008'*********************************************************************************Option ExplicitDim arrFileLines()Dim tstDim i, j, k, lDim objFSO, objFile, objDialog, objExcel, objWMIService, objService, objWorkbookDim WshShellDim colServicesDim srcFileName'source fileDim intResultDim strComputer'computer to inventory'ConstantsConst xlLeft = -4131Const xlHorizontal = -4128'Set ObjectsSet objExcel = CreateObject("Excel.Application")Set objDialog = CreateObject("UserAccounts.CommonDialog")Set WshShell = WScript.CreateObject("WScript.Shell")'Open the source file that contains the list of computersobjDialog.Filter = "Text Files|*.txt"objDialog.InitialDir = WshShell.SpecialFolders("Desktop")intResult = objDialog.ShowOpen If intResult = 0 ThenWscript.QuitElse'Set selected file to srcFileNamesrcFileName = objDialog.FileNamei = 0Set objFSO = CreateObject("Scripting.FileSystemObject")Set objFile = objFSO.OpenTextFile(srcFileName, 1)Do Until objFile.AtEndOfStreamRedim Preserve arrFileLines(i)arrFileLines(i) = objFile.ReadLinei = i + 1LoopobjFile.Close'*********************************************************************************' Create a new Excel Workboot'*********************************************************************************objExcel.Visible = TrueSet objWorkbook = objExcel.Workbooks.Add()'*********************************************************************************'Loop through the array of computers, create a worksheet with the computer name,
Leave a Comment