指定的可执行文件不是有效的Win32应用程序 [英] The specified executable is not a valid Win32 application

查看:357
本文介绍了指定的可执行文件不是有效的Win32应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调试以下代码时,出现了以上错误.有人可以帮我解决这个问题吗?
提前谢谢.

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");
		}

推荐答案

那是因为您需要执行安装程序而不是软件包本身.请参阅本文: C#-安装和卸载软件 [
That''s because you need to execute the installation program instead of the package itself. See this article: C# - Installing and uninstalling software[^]


MSI文件必须通过,并且您不能使用Process.Start()直接调用* .msi文件.

尝试以下方法:
MSI files must be installed via the MSIEXEC.EXE and you cannot call the *.msi file directly using the Process.Start().

Try the following :
myProcess.StartInfo.FileName = "MSIEXEC.EXE";
myProcess.StartInfo.Arguments = "/i /q \"" + installationPackages[i] + "\"";


这篇关于指定的可执行文件不是有效的Win32应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆