VBS ile İşletim Sisteminin Servislerini ve Çalışma Durumlarını Listelemek

Başlatan Bülent, Ekm 08, 2017, 04:43 ÖS

« önceki - sonraki »

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Bülent

VBS ile İşletim Sisteminin Servislerini ve Çalışma Durumlarını Listelemek:

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()
Set objWorksheet = objWorkbook.Worksheets(1)
x = 1

strComputer = "."
Set objWMIService = _
    GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_Service")
For Each objItem in colItems
    objWorksheet.Cells(x, 1) = objItem.Name
    objWorksheet.Cells(x, 2) = objItem.DisplayName
    objWorksheet.Cells(x, 3) = objItem.State
    x = x + 1
Next

Set objRange = objWorksheet.UsedRange
objRange.EntireColumn.Autofit()

Bülent

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add

x = 1
strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\cimv2")
Set colServices = objWMIService.ExecQuery _
    ("Select * From Win32_Service")

For Each objService in colServices
    objExcel.Cells(x, 1) = objService.Name
    objExcel.Cells(x, 2) = objService.State
    x = x + 1
Next