Stop windows service using java


















Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Need a way to check status of Windows service programmatically Ask Question. Asked 13 years, 1 month ago. Active 1 month ago. Viewed 28k times. Here is the situation: I have been called upon to work with InstallAnywhere 8, a Java-based installer IDE, of sorts, that allows starting and stopping of windows services, but has no built-in method to query their states.

I just need something that will tell me if a specific service is started or stopped. Any suggestions or criticisms are welcome. Troy Troy 1 1 gold badge 10 10 silver badges 18 18 bronze badges. Add a comment. Active Oldest Votes. It's ugly, but it works beautifully. Yuval Yuval 7, 11 11 gold badges 38 38 silver badges 54 54 bronze badges. You can create a small VBS on-th-fly, launch it and capture its return code. File; import java. Next, I download the Java Runtime and also copy it into this folder.

This is optional. Your service can access a globally installed Java. But I like to have everything contained in one folder and don't have to worry about somebody updating or removing the globally installed Java. I usually download Java from Adoptium. Download the ZIP file and unzip it into the install folder. I unzip it into the java subfolder, so the java. Open the release page of the WinSW project and download the executable suitable for your platform.

For this demo installation, I download WinSW. WinSW runs on Windows with. Find the PID — Then execute the below command with the service name identified above. All done. You can now start your service now. Unfortunately, now I need to reopen it because a program needs window update security to open it after a long time. What should I do? Save my name, email, and website in this browser for the next time I comment.

This wrapper is used by both Tomcat and JBoss Wildfly to wrap their servers — but it took a bit of figuring out how to get my application running. I downloaded procrun from here. The download contains three different version of the procrun. You don't need to create a service. Store this in your code directory. The final trick is to use prunmgr.



0コメント

  • 1000 / 1000