我想开始这两项服务:
String s7 = "OracleDBConsoleorcl";
String s8 = "Oracle ORCL VSS Write Service";
使用此方法:
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);
}
}
这是问题:s7正常启动但s8没有,因为(我的猜测)是服务名称包含空格,导致此错误:
[SC] StartService: OpenService FAILED 1060:
The specified service does not exist as an installed service.
我的意思是,服务存在于此处:
我能尝试什么?我确实尝试过String s8 =“\”Oracle ORCL VSS Write Service \“”;给cmd正确的格式但不起作用...
答案 0 :(得分:2)
显示的字符串不是真实/内部服务名称。
在服务列表中打开该条目的属性,您可以看到其服务名称(不包含空格)。