Click here to Skip to main content
15,899,124 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
While debugging this following code i have got this above error. can anyone help me to solve this?
Thanks in advance.

private static void InstallSoftware()
		{
			if (installoperations.InstallSoftware == false)
				return;

			string[] installationPackages = System.IO.Directory.GetFiles(Application.StartupPath, "*.msi");
			for (int i = 0; i < installationPackages.Length; i++)
			{
				Process myProcess = new Process();
				myProcess.StartInfo.FileName = installationPackages[i];
				myProcess.StartInfo.Arguments = "";
				myProcess.StartInfo.UseShellExecute = false;
				myProcess.Start();
				Process installp = Process.GetProcessById(myProcess.Id);
				if (installp != null)
					installp.WaitForExit();
			}

			MessageBox.Show("Software Installation Completed");
		}
Posted

That's because you need to execute the installation program instead of the package itself. See this article: C# - Installing and uninstalling software[^]
 
Share this answer
 
Comments
sahabiswarup 6-Dec-11 5:50am    
thanks for this above link
Kislay Raj 12-Aug-12 13:02pm    
not solved my problem
OriginalGriff 13-Aug-12 4:09am    
Then you need to ask a question of your own, and give sufficient detail to get a more specific answer.
Kislay Raj 14-Aug-12 3:30am    
I have create that program using visual c# express and create setup using inno setup compiler setup has been done and I found the error now:
Below is a summary of the errors, details of these errors are listed later in the log.
* Activation of C:\Users\KislayA\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\TSMS\TSMS.appref-ms| resulted in exception. Following failure messages were detected:

+ is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
OriginalGriff 14-Aug-12 3:44am    
No, you need to start a new Quick Answers question. Go here:
http://www.codeproject.com/Questions/ask.aspx
And post as much relevant detail as you can.

Posting a different (but sort of similar) question as a comment is considered as hijacking a thread!
MSI files must be installed via the MSIEXEC.EXE and you cannot call the *.msi file directly using the Process.Start().

Try the following :
C#
myProcess.StartInfo.FileName = "MSIEXEC.EXE";
myProcess.StartInfo.Arguments = "/i /q \"" + installationPackages[i] + "\"";
 
Share this answer
 
Comments
Kislay Raj 12-Aug-12 13:04pm    
no I have try it and I think you should replace the installationPackages[i] to the application name

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