I am looking for a library that will allow me to look up the status of a windows service to verify that the service is started and running. I looked into the Sigar library, but it is GPL and therefor I cannot use it. A Commercial or BSD(ish) license is required as this will be bundled into commercial software.
Windows has always used the Services panel as a way to manage the services that are running on your computer. You can easily get there at any point by simply hitting WIN + R on your keyboard to open the Run dialog, and typing in services. msc.
Go to Server > Server Monitor > Servers > click on the desired monitor. Go to Services and Processes tab. Click on Discover Services and Processes . This will discover the processes & services running in your Windows server.
Top Windows command-line commands Anytime you want to know what services are installed on a computer and find out which ones are active, you can use sc query state= all to find a complete list. If the computer in question is remote, you should use sc \\computername query state= all.
If nothing else helps, try to think of a slightly different approach (if you can, of course), e.g.:
I don't think there is any pure-Java way to do this because some operating systems don't have the notion of "services" like Windows does. In our projects, we wrote a wrapper around calls to the "sc" command from the command line. To get the status of a service, you can do:
sc \\some-computer query "my service name"
You'll have to manually parse the output but it's pretty straightforward.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With