if(!dstSlaveJar.exists()) // perhaps slave.jar is already there?
FileUtils.copyURLToFile(slaveJar,dstSlaveJar);
// install as a service
ByteArrayOutputStream baos = new ByteArrayOutputStream();
StreamTaskListener task = new StreamTaskListener(baos);
r = runElevated(slaveExe,"install",task,dir);
if(r!=0) {
JOptionPane.showMessageDialog(
dialog,baos.toString(),"Error", ERROR_MESSAGE);
return;
}
r = JOptionPane.showConfirmDialog(dialog,
Messages.WindowsSlaveInstaller_InstallationSuccessful(),
Messages.WindowsInstallerLink_DisplayName(), OK_CANCEL_OPTION);
if(r!=JOptionPane.OK_OPTION) return;
// let the service start after we close our connection, to avoid conflicts
Runtime.getRuntime().addShutdownHook(new Thread("service starter") {
public void run() {
try {
StreamTaskListener task = StreamTaskListener.fromStdout();
int r = runElevated(slaveExe,"start",task,dir);
task.getLogger().println(r==0?"Successfully started":"start service failed. Exit code="+r);
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}