Bala
Bala

Reputation: 204

msi installer is not working with apache commons exec throws exit code 1639

I am trying to install a software with .msi file and it is working fine when I try in the Windows command prompt. But the same is not working in apache commons exec. When I run thru apache commons exec, it says exit code 1639 and the product is not getting installed.

Command prompt code:

msiexec /i "C:\Automation\Products\product_name.msi" /passive INSTALLDIR="C:\Program Files\product_name" PROCESSINGTEMPFOLDER="C:\ProgramData\Auto\Temp" SERVICEUSER="user1" SERVICEDOMAIN="abc.groupcom.net" SERVICEPASS="samplepwd" /lv "C:\Automation\Products\Install.log"

Apache Commons exec code:

log.info("Executing install command...");
String command = "msiexec /i \"C:\\Automation\\Products\\product_name.msi\" /passive INSTALLDIR=\"C:\\Program Files\\product_name\" PROCESSINGTEMPFOLDER=\"C:\\ProgramData\\Auto\\Temp\" SERVICEUSER=\"user1\" SERVICEDOMAIN=\"abc.groupcom.net\" SERVICEPASS=\"samplepwd\" /lv \"C:\\Automation\\Products\\Install.log\"";
CommandLine cmdLine = CommandLine.parse("cmd /c "+command);
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(0);
int exitValue = executor.execute(cmdLine);
if(exitValue != 0) {
    throw new Exception("Error while executing the command..."+command+"::::Exit Value: "+exitValue);
}

I have used java ProcessBuilder and java Process as well, both are giving the same output. But it is working fine and the product gets installed via Command Prompt.

In order to avoid the UAC popup, I run my executable jar file thru Task Scheduler with Highest Priviledges.

Here is a working .exe file command from apache commons exec which is an exe file, but the same is not working for .msi files.

"C:\Automation\Products\product_name.exe" /i /ComponentArgs "*":"/qn /norestart"

Kindly help me to go thru this error.

EDIT: Below code also did not worked.

log.info("Executing install command...");
String command = "msiexec";
String args = "/i \"C:\\Automation\\Products\\product_name.msi\" /passive INSTALLDIR=\"C:\\Program Files\\product_name\" PROCESSINGTEMPFOLDER=\"C:\\ProgramData\\Auto\\Temp\" SERVICEUSER=\"user1\" SERVICEDOMAIN=\"abc.groupcom.net\" SERVICEPASS=\"samplepwd\" /lv \"C:\\Automation\\Products\\Install.log\"";
CommandLine cmdLine = new CommandLine(command);
cmdLine.addArguments(args);
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(0);
int exitValue = executor.execute(cmdLine);
if(exitValue != 0) {
    throw new Exception("Error while executing the command..."+command+"::::Exit Value: "+exitValue);
}

Upvotes: 0

Views: 91

Answers (0)

Related Questions