Beruflich Dokumente
Kultur Dokumente
Option Explicit
Dim arrFileLines()
Dim tst
Dim i, j, k, l
Dim objFSO, objFile, objDialog, objExcel, objWMIService, objService, objWorkbook
Dim WshShell
Dim colServices
Dim srcFileName 'source file
Dim intResult
Dim strComputer 'computer to inventory
'Constants
Const xlLeft = -4131
Const xlHorizontal = -4128
'Set Objects
Set objExcel = CreateObject("Excel.Application")
Set objDialog = CreateObject("UserAccounts.CommonDialog")
Set WshShell = WScript.CreateObject("WScript.Shell")
If intResult = 0 Then
Wscript.Quit
Else
'Set selected file to srcFileName
srcFileName = objDialog.FileName
i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(srcFileName, 1)
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close
'*********************************************************************************
' Create a new Excel Workboot
'*********************************************************************************
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()
'*********************************************************************************
'Loop through the array of computers, create a worksheet with the computer name,
' get the list of services,
' and write out the services to the excel sheet
'*********************************************************************************
k = 3
objExcel.Worksheets("Sheet1").Delete
objExcel.Worksheets("Sheet2").Delete
'*********************************************************************************
'Services Information
'*********************************************************************************
i = 1
j = 1
'Column headers
objExcel.Cells(i, j).Value = "Service"
objExcel.Cells(i, j).Font.Bold = TRUE
j = j + 1
objExcel.Cells(i, j).Value = "Status"
objExcel.Cells(i, j).Font.Bold = TRUE
j = j + 1
objExcel.Cells(i, j).Value = "Start Mode"
objExcel.Cells(i, j).Font.Bold = TRUE
j = j + 1
objExcel.Cells(i, j).Value = "Start Name"
objExcel.Cells(i, j).Font.Bold = TRUE
j = j + 1
objExcel.Cells(i, j).Value = "Path Name"
objExcel.Cells(i, j).Font.Bold = TRUE
'Services data
For Each objService in colServices
i = i + 1
j = 1
objExcel.Cells(i, j) = objService.Name
j = j + 1
objExcel.Cells(i, j) = objService.State
j = j + 1
objExcel.Cells(i, j) = objService.StartMode
j = j + 1
objExcel.Cells(i, j) = objService.StartName
j = j + 1
objExcel.Cells(i, j) = objService.PathName
Next
' Autofit the first column to fit the longest service name
objExcel.Columns("A:Z").EntireColumn.AutoFit
objExcel.Columns("A:Z").HorizontalAlignment = xlLeft
k = k + 1
Next
'Close Excel
objExcel.Quit
End If
'*********************************************************************************
'Cleanup
'*********************************************************************************
'Cleanup objects
Wscript.Quit 0