How do I know if service is running using batch file in MAUI app?

Dani_S 3,786 Reputation points
2022-09-12T12:59:38.78+00:00

Hi,
How do I know if service is running using batch file in MAUI app?
Thanks,
Dani

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,542 questions
{count} votes

Accepted answer
  1. Michael Taylor 54,401 Reputation points
    2022-09-12T15:09:33.82+00:00

    What do you mean by "service"? Windows services? API services hosted on a remote server?

    I wouldn't recommend using a batch file in any app unless you absolutely need to. There is no benefit and it is harder to do. If you want to get Windows services then you can use the System.ServiceProcess.ServiceController class. However this is a Windows-only thing so you'll need to properly wrap this in platform code. You'll also need to add a NuGet package for System.ServiceProcess. After that however you can get the service(s) you care about and check their status.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.