Click here to Skip to main content
15,793,846 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a simple app that extracts the contents of an MSI. The code looks like this
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "msiexec ";
startInfo.Arguments = "/a  \"" + textBox1.Text + "\"  /qb TARGETDIR=\""+ textBox1.Text +".EXT\"";
process.StartInfo = startInfo;

the MessageBox displays the correct syntax but the application generates an error stating file specified not found .

If I copy the contest of a messagebox into a batch file and then run the batch file like this

Then that works fine.
What am I missing? Any help is greatly appreciated
Updated 16-Feb-15 20:14pm
TheRealSteveJudge 17-Feb-15 2:37am    
Can you try to set the working directory to "c:\temp"?
startInfo.WorkingDirectory = "c:\\temp"

Change your Arguments property string to something more readable:
startInfo.Arguments = string.Format("/a \"{0}\" /qb TARGETDIR=\"{1}.EXT\"", textBox1.Text, textBox1.Text);

Without knowing what you input, it's impossible to tell you what's really wrong. Are you providing a COMPLETE path to the target file or are you, foolishly, relying on relative path names?

The only other thing that may be wrong is why are you putting an extension on the path you pass to TARGETDIR?? Does the TARGETDIR directory structure exist before you try and execute this command?
Share this answer
picasso2 17-Feb-15 23:38pm    
both your code and my code result in same output
msiexec /a "C:\Temp\MyApplication.msi" /qb TARGETDIR="C:\Temp\MyApplication.msi"

this will not run but if I copy to a batch file and then run , works fine.
-The destination folder is the same name as the msi that is why I added an EXT (extracted)to define is a extracted folder
-No the folder does not exist in the target
-path is complete and correct as you can see by the output

I will try to create the folder target first now
Dave Kreskowiak 18-Feb-15 9:42am    
I didn't say it would make your command line work. I just said it's more readable and therefor easier to debug and support.

The problem is that you're passing the path to the MSI file to TARGETDIR. That property requires a path to a directory, not an .MSI. It's OK to use the name of the msi as a folder name, but you cannot have a file and folder with the exact same name in the same parent folder.
Many thank Dave for taking the time to post your recommendations.  I changed the argument as follows:

startInfo.Arguments = " /a  \"" + textBox1.Text + "\" /qb  TARGETDIR=\"C:\\Temp\\" + trimStrg + ".Ext\"" + "  /L*v  \"c:\\temp\\" + trimStrg + ".log\"";

this did the trick
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900