Java services with a special name

I want to start these 2 services:

String s7 = "OracleDBConsoleorcl";
String s8 = "Oracle ORCL VSS Write Service";  

      

Using this method:

private void startService(String SERVICE_NAME) {
    String[] script = {"cmd.exe", "/c", "sc", "start", SERVICE_NAME};//to start service

    try {
        Process p = Runtime.getRuntime().exec(script);
        p.waitFor();
        BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String line = reader.readLine();
        while (line != null) {
            if (line.equals("0")) {
                System.out.println(line);
            } else {
                System.out.println(line);
            }
            line = reader.readLine();
        }

    } catch (IOException | InterruptedException e1) {
        System.out.println(e1);
    }
}

      

This is the problem: s7 starts up correctly, but s8 doesn't, because (my guess) is that the service name contains spaces, leading to this error:

[SC] StartService: OpenService FAILED 1060:
The specified service does not exist as an installed service.  

      

I mean the service exists here:

oracleProblem

What can I try? I tried String s8 = "\" Oracle ORCL VSS Write Service \ ""; to give cmd the correct format but doesn't work ...

+3


source to share


1 answer


The displayed string is not the true / internal name of the service.



Open the properties of this entry in the list of services and you will see its service name (which does not contain spaces).

+2


source







All Articles