Sign in to follow this  
Followers 0
rudi

how to get a list of *INSTALLED* services?

4 posts in this topic

Hello,

running services I can list with

net start

but then I will need to work with a spool file to process the list.

Is there a direct way to get a list of the current settings of all installed services directly?

service name

service's exe file and it's location

service startup type

current service status (running, stopped, starting, stopping)

service dependencies?

Thanks for any suggestions,

regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites



You could roll your own with WMI. This example includes way more than you need though.

; Generated by AutoIt Scriptomatic

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Service", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output = $Output & "AcceptPause: " & $objItem.AcceptPause & @CRLF
      $Output = $Output & "AcceptStop: " & $objItem.AcceptStop & @CRLF
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $Output = $Output & "CheckPoint: " & $objItem.CheckPoint & @CRLF
      $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "DesktopInteract: " & $objItem.DesktopInteract & @CRLF
      $Output = $Output & "DisplayName: " & $objItem.DisplayName & @CRLF
      $Output = $Output & "ErrorControl: " & $objItem.ErrorControl & @CRLF
      $Output = $Output & "ExitCode: " & $objItem.ExitCode & @CRLF
      $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output = $Output & "Name: " & $objItem.Name & @CRLF
      $Output = $Output & "PathName: " & $objItem.PathName & @CRLF
      $Output = $Output & "ProcessId: " & $objItem.ProcessId & @CRLF
      $Output = $Output & "ServiceSpecificExitCode: " & $objItem.ServiceSpecificExitCode & @CRLF
      $Output = $Output & "ServiceType: " & $objItem.ServiceType & @CRLF
      $Output = $Output & "Started: " & $objItem.Started & @CRLF
      $Output = $Output & "StartMode: " & $objItem.StartMode & @CRLF
      $Output = $Output & "StartName: " & $objItem.StartName & @CRLF
      $Output = $Output & "State: " & $objItem.State & @CRLF
      $Output = $Output & "Status: " & $objItem.Status & @CRLF
      $Output = $Output & "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF
      $Output = $Output & "SystemName: " & $objItem.SystemName & @CRLF
      $Output = $Output & "TagId: " & $objItem.TagId & @CRLF
      $Output = $Output & "WaitHint: " & $objItem.WaitHint & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      
      ;Seperate message box for each service
      ;$Output=""
      
      ;One big message
      $Output &= @CRLF
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Service" )
Endif


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

Share this post


Link to post
Share on other sites

Thanks to both of you.

That's very close to what I was looking for!

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0