1 18 19 package sync4j.syncclient.spap.launcher; 20 21 import java.io.File ; 22 import java.io.IOException ; 23 24 import sync4j.syncclient.common.logging.Logger; 25 import sync4j.syncclient.spap.AssetInstallationException; 26 import sync4j.syncclient.spap.installer.InstallationContext; 27 28 35 36 public class Win32Launcher implements Launcher { 37 38 39 41 private Logger logger = new Logger(); 42 43 45 55 public int execute(String programName, boolean install, InstallationContext ctx) 56 throws AssetInstallationException { 57 58 String completeProgramPath = ctx.getWorkingDirectory() + File.separator + programName; 59 if (logger.isLoggable(Logger.DEBUG)) { 60 logger.debug("Win32Launcher - Execute " + 61 completeProgramPath ); 62 } 63 64 int exitState = -1; 65 try { 66 Process proc = Runtime.getRuntime().exec( 67 completeProgramPath, null, new File (ctx.getWorkingDirectory()) 68 ); 69 70 proc.waitFor(); 71 72 exitState = proc.exitValue(); 73 74 if (logger.isLoggable(Logger.DEBUG)) { 75 logger.debug("Process executed. Return state: " + exitState); 76 } 77 78 } catch (Exception e) { 79 throw new AssetInstallationException("Error launching '" + completeProgramPath + "'", e); 80 } 81 82 return exitState; 83 } 84 85 86 } | Popular Tags |