Jump to content

_Service_GetStartType


Ontosy
 Share

Recommended Posts

Did you mean StartMode?

; Generated by AutoIt Scriptomatic January 13, 2013

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

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

If IsObj($colItems) then
For $objItem In $colItems
     $Output &= "AcceptPause: " & $objItem.AcceptPause & @CRLF
     $Output &= "AcceptStop: " & $objItem.AcceptStop & @CRLF
     $Output &= "Caption: " & $objItem.Caption & @CRLF
     $Output &= "CheckPoint: " & $objItem.CheckPoint & @CRLF
     $Output &= "CreationClassName: " & $objItem.CreationClassName & @CRLF
     $Output &= "Description: " & $objItem.Description & @CRLF
     $Output &= "DesktopInteract: " & $objItem.DesktopInteract & @CRLF
     $Output &= "DisplayName: " & $objItem.DisplayName & @CRLF
     $Output &= "ErrorControl: " & $objItem.ErrorControl & @CRLF
     $Output &= "ExitCode: " & $objItem.ExitCode & @CRLF
     $Output &= "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
     $Output &= "Name: " & $objItem.Name & @CRLF
     $Output &= "PathName: " & $objItem.PathName & @CRLF
     $Output &= "ProcessId: " & $objItem.ProcessId & @CRLF
     $Output &= "ServiceSpecificExitCode: " & $objItem.ServiceSpecificExitCode & @CRLF
     $Output &= "ServiceType: " & $objItem.ServiceType & @CRLF
     $Output &= "Started: " & $objItem.Started & @CRLF
     $Output &= "StartMode: " & $objItem.StartMode & @CRLF
     $Output &= "StartName: " & $objItem.StartName & @CRLF
     $Output &= "State: " & $objItem.State & @CRLF
     $Output &= "Status: " & $objItem.Status & @CRLF
     $Output &= "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF
     $Output &= "SystemName: " & $objItem.SystemName & @CRLF
     $Output &= "TagId: " & $objItem.TagId & @CRLF
     $Output &= "WaitHint: " & $objItem.WaitHint & @CRLF
     if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
     $Output=""
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

Edit:

Here's another WMI query which contains a "StartType", but sadly this query does not finish for me...

; Generated by AutoIt Scriptomatic January 13, 2013

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

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

If IsObj($colItems) then
   For $objItem In $colItems
      $Output &= "Caption: " & $objItem.Caption & @CRLF
      $Output &= "CheckID: " & $objItem.CheckID & @CRLF
      $Output &= "CheckMode: " & $objItem.CheckMode & @CRLF
      $Output &= "Dependencies: " & $objItem.Dependencies & @CRLF
      $Output &= "Description: " & $objItem.Description & @CRLF
      $Output &= "DisplayName: " & $objItem.DisplayName & @CRLF
      $Output &= "ErrorControl: " & $objItem.ErrorControl & @CRLF
      $Output &= "ID: " & $objItem.ID & @CRLF
      $Output &= "LoadOrderGroup: " & $objItem.LoadOrderGroup & @CRLF
      $Output &= "Name: " & $objItem.Name & @CRLF
      $Output &= "Password: " & $objItem.Password & @CRLF
      $Output &= "ServiceType: " & $objItem.ServiceType & @CRLF
      $Output &= "SoftwareElementID: " & $objItem.SoftwareElementID & @CRLF
      $Output &= "SoftwareElementState: " & $objItem.SoftwareElementState & @CRLF
      $Output &= "StartName: " & $objItem.StartName & @CRLF
      $Output &= "StartType: " & $objItem.StartType & @CRLF
      $Output &= "TargetOperatingSystem: " & $objItem.TargetOperatingSystem & @CRLF
      $Output &= "Version: " & $objItem.Version & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ServiceSpecification" )
Endif
Edited by KaFu
Link to comment
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
 Share

×
×
  • Create New...