jerhynsoen
jerhynsoen

Reputation: 215

run a .msi file in java

So I try to run a .msi file like I would an exe file, which may be the problem. I get this error message

java.io.IOException: Cannot run program "\": CreateProcess error=193, %1 is not a valid Win32 application

       try {   Runtime rf = Runtime.getRuntime(); 
                   Process pf = rf.exec("\\IE8fix.msi");    
                } catch(Exception e) {                 
                    System.out.println(e.toString());                 
                            e.printStackTrace();
                                                    } 

Upvotes: 0

Views: 2988

Answers (2)

DankMemes
DankMemes

Reputation: 2137

Windows installer is in %windir%\msiexec.exe An MSI file is not standalone. It needs to be run like msiexec \"file.msi\" So use:

try {
   Runtime rf = Runtime.getRuntime(); 
   Process pf = rf.exec("msiexec /i \"\\IE8fix.msi\"");    
} catch(Exception e) {                 
   //System.out.println(e.toString()); // not necessary       
   e.printStackTrace();
} 

Upvotes: 5

JimmyMcHoover
JimmyMcHoover

Reputation: 864

An .msi file is not a standalone program like an exe, it should run from the Windows Installer something like this (i hope this is correct):

Process pf = rf.exec("msiexec \"\\IE8fix.msi\"");    

Upvotes: 0

Related Questions