Randon question about software and services.msc

Discussion in 'Webmastering & Programming' started by Flybye, Jul 9, 2019.

  1. Flybye

    Flybye Limp Gawd

    Messages:
    195
    Joined:
    Jun 29, 2006
    Say you have a piece of hardware that talks to a program which has a service that, when enabled, allows the hardware to talk to a specific website through IE. If the service is running, is it possible for the program to detect if the service has the Startup Type to manual or automatic? And if set to manual to then prevent the hardware from communicating to the website?
     
  2. JVene

    JVene n00b

    Messages:
    18
    Joined:
    Apr 25, 2019
    You're looking for Windows documentation for the function QueryServiceConfig (and related functions and materials), which would allow a program to inquire as to the startup setting and chose actions accordingly.
     
    GoldenTiger likes this.
  3. Absalom

    Absalom Gawd

    Messages:
    618
    Joined:
    Oct 3, 2007
    While JVene's answer is a perfectly valid solution, I thought I'd share an alternative solution for those, eh, more programming-challenged.

    You can use the following PowerShell commands to query the service's running status and startup type respectively:
    Code:
    Get-Service -Name "Bonjour Service"
    
    Get-Service -Name "Bonjour Service" | select -property name,starttype
    Then it's a matter of parsing the output.
     
  4. Flybye

    Flybye Limp Gawd

    Messages:
    195
    Joined:
    Jun 29, 2006
    Thanks, guys! I just wanted to know how possible is it, and it certainly is. I noticed software only communicating after the startup value was set to automatic. I thought that was very interesting as I've never seen a program use that value as a trigger, but now I know it is totally valid. TY