Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8624653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:35:01+00:00 2026-06-12T07:35:01+00:00

i have windows services now i want to stop and start window services using

  • 0

i have windows services now i want to stop and start window services using jsp page means, in my jsp page there is a buttons start and stop when we click on those buttons then it should be stop and start service, i use some commands like this

public static int stopService(String serviceName) throws Exception {

return execCmd("cmd /c net stop \" + serviceName + "\"");

}

please anyone provide some guidance to this, thank u inadvance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:35:02+00:00Added an answer on June 12, 2026 at 7:35 am

    Use process.

    Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);
    int processComplete = runtimeProcess.waitFor();
    

    Detail coding works

    import java.io.IOException;
    import java.util.Calendar;
    import java.util.Date;
    
    public class program7 {
    
        public static void main(String args[]) {
            String serviceName = ""; // Insert your service name
            try {
                stopService(serviceName);
            } catch (IOException e) {
                e.printStackTrace();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
    
        }
    
        public static void stopService(String serviceName) throws IOException,
                InterruptedException {
    
            String executeCmd = "cmd /c net stop \"" + serviceName + "\"";
            Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);
            int processComplete = runtimeProcess.waitFor();
    
            System.out.println("processComplete: " + processComplete);
    
            if (processComplete == 1) {// if values equal 1 process failed
                System.out.println("Service failed");
            }
    
            else if (processComplete == 0) {
                System.out.println("Service Success");
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created simple application in windows sharepoint services. Now I want to deploy
I have created windows services which perform some functions. Now I want to install
I have a windows service which will start and stop the execution of some
I'm working on 2 Windows Services that have a common database which I want
Right now i have some sort of services application on windows server 2003 for
I have a Windows service that is written in C++ using VS2008. I now
Let's say I have two windows services running. One service is 'Polling' - it
I have a few Windows Services written in C# that I have setup to
We have about 7 app servers running .NET windows services that ping a single
I have been quite comfortable with windows-services, I have been practicing since from last

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.