Forum Stats

  • 3,871,973 Users
  • 2,266,360 Discussions


Write a Java application that allows users to restart Windows services

paulcarron Member Posts: 3
edited Nov 8, 2016 6:01AM in Java Desktop Applications

Please bear with me. I haven't done any Java programming in about 10 years so this is likely to be a steep learning curve.

I'd like to write a Java application that sits on a users desktop and can be used to restart one of 3 specific services on a remote windows 2012 server.

My initial thought is that the service would be selected from a dropdown and the restart initiated with the click of a button.

The users aren't administrators on the server so I'd like to empower them with permissions to restart these services(only these services).

Can anybody please advise where I might begin with this? If there's anywhere with information on doing something similar I'd greatly appreciate it. Also, am I biting off too much too soon? Right now I'm not even sure where to begin.

Anyway, learn by doing. That's always been my attitude so here's hoping!


  • paulcarron
    paulcarron Member Posts: 3
    edited Nov 8, 2016 6:01AM


    I've got this code:


    public class AtlasServiceStartStop {

        public static void main(String[] args){

            // you can pass query/start/stop to respective


            String[] command = {"cmd.exe", "/c", "sc", "\\\\", "query", "\"Atlas 5.1.3580 AX2012R2 OTHER Service\""};

            try {

                Process process = new ProcessBuilder(command).start();

                InputStream inputStream = process.getInputStream();

                InputStreamReader inputStreamReader = new InputStreamReader(inputStream);

                BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

                String line;

            while ((line = bufferedReader.readLine()) != null) {



            } catch(Exception ex) {

            System.out.println("Exception : "+ex);




    It returns the status of the service.

    I can change "query" to "stop" or "start" and re run the application to stop and start the service.

    I'm now trying to create these as methods so I can have a query, stop and start method?

    I'll post the details if I figure it out myself.

This discussion has been closed.