Yeah you can also use

C:\WINDOWS\system32>net start | findstr "Jen"
   Jenkins

C:\WINDOWS\system32>

but it sounds to me like you have a wider use case here. Maybe you'd like
to explain it?



On Wed, Dec 4, 2019 at 2:14 AM Adakar <[email protected]> wrote:

> Hi Jonathan,
>
> Thank you for the answer! I know that I can check that with the help of
> the "sc query <name>"
> A problem I see with this solution is the lack of knowledge about the
> service name. Services can be installed under custom names(e.g.
> jenkinsslave-D__tmp_win_Agent), right?
> I wonder if there is a Jenkins Java API to get information about the name
> or if the agent was started as a service?
> So far I found that the plugin sees the WINSW_SERVICE_ID env variable when
> the agent is running as a service but I'm not sure if this check is
> reliable and sufficient.
>
> BR, Adakar
>
> W dniu wtorek, 3 grudnia 2019 16:56:54 UTC+1 użytkownik Jonathan Mackenzie
> napisał:
>>
>> C:\WINDOWS\system32>sc query "jenkins"
>>
>> SERVICE_NAME: jenkins
>>         TYPE               : 10  WIN32_OWN_PROCESS
>>         STATE              : 4  RUNNING
>>                                 (STOPPABLE, NOT_PAUSABLE,
>> ACCEPTS_SHUTDOWN)
>>         WIN32_EXIT_CODE    : 0  (0x0)
>>         SERVICE_EXIT_CODE  : 0  (0x0)
>>         CHECKPOINT         : 0x0
>>         WAIT_HINT          : 0x0
>>
>> C:\WINDOWS\system32>sc query "fred"
>> [SC] EnumQueryServicesStatus:OpenService FAILED 1060:
>>
>> The specified service does not exist as an installed service.
>>
>>
>> C:\WINDOWS\system32>
>>
>> On Tue, Dec 3, 2019 at 5:56 AM Adakar <[email protected]> wrote:
>>
>>> Hi There :)
>>>
>>> I'm working on a Jenkins plugin. I'm looking for a way to check if the
>>> Jenkins agent is running as a Windows service. So far my idea is to check
>>> if the WINSW_SERVICE_ID is set. Is there any other way? Any suggestions are
>>> highly appreciated :)
>>>
>>> BR, Adakar
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Jenkins Developers" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com
>>> <https://groups.google.com/d/msgid/jenkinsci-dev/3193b476-8414-4c83-a3f3-a45cd6cbe1b5%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-dev/6599e4e8-fded-4ab2-8e72-0651f718d9e9%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-dev/6599e4e8-fded-4ab2-8e72-0651f718d9e9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CAO1vCWGAJUwJcyJvHihM3_DJPNmkNusYNG3YiqFyTQM%2B0jwp0A%40mail.gmail.com.

Reply via email to