C# 在C中的Cusom操作中进行静默安装时出现的问题#

C# 在C中的Cusom操作中进行静默安装时出现的问题#,c#,custom-action,silent-installer,C#,Custom Action,Silent Installer,我想在用C#编写的自定义操作中静默安装一个名为Instacal的应用程序。在这个自定义操作中,我还安装了其他应用程序,效果很好(它们不是以静默方式安装的!) 当启动名为Instacal的应用程序的静默安装时,不会安装任何东西(我检查程序和功能)。在自定义操作中,我执行以下操作: int ms = 0; // execute InstaCal silently - it must be present on the user machine! var fileName = Path.Combine

我想在用C#编写的自定义操作中静默安装一个名为Instacal的应用程序。在这个自定义操作中,我还安装了其他应用程序,效果很好(它们不是以静默方式安装的!)

当启动名为Instacal的应用程序的静默安装时,不会安装任何东西(我检查程序和功能)。在自定义操作中,我执行以下操作:

int ms = 0;
// execute InstaCal silently - it must be present on the user machine!
var fileName = Path.Combine(folder3rdParty, @"Instacal\InstaCal.msi");
Process installerProcess;
installerProcess = Process.Start(fileName, "/q");
while (installerProcess.HasExited == false)
{
     StreamWriter file = new StreamWriter("c:\\test.txt", true);
     file.WriteLine("ms: " + ms);
     file.Close();

     Thread.Sleep(250);
     ms += 250;
}
我写一个文件只是为了测试安装大约需要多长时间。在while循环中大约需要3秒钟,然后什么也没有安装

但是,如果我在一个小型控制台应用程序中使用完全相同的代码,那么应用程序Instacal将成功地以静默方式安装。完成此安装大约需要9秒钟


那么,我是不是在代码中做错了什么?我是否遗漏了一些关于自定义操作的重要信息?thx:)

我建议您将代码更改为以下内容:

int ms = 0;
// execute InstaCal silently - it must be present on the user machine!
var fileName = Path.Combine(folder3rdParty, @"Instacal\InstaCal.msi");
Process installerProcess;
installerProcess = Process.Start(fileName, "/q");
while (installerProcess.HasExited == false)
{
     StreamWriter file = new StreamWriter("c:\\test.txt", true);
     file.WriteLine("ms: " + ms);
     file.Close();

     Thread.Sleep(250);
     ms += 250;
}
然后使用MSIEXEC命令安装程序包,而不是直接调用MSI

int ms = 0;
// execute InstaCal silently - it must be present on the user machine!
var fileName = Path.Combine(folder3rdParty, @"Instacal\InstaCal.msi");
Process installerProcess;
installerProcess = Process.Start("msiexec", string.Format("/i '{0}' /q", fileName));
while (installerProcess.HasExited == false)
{
     StreamWriter file = new StreamWriter("c:\\test.txt", true);
     file.WriteLine("ms: " + ms);
     file.Close();

     Thread.Sleep(250);
     ms += 250;
}

您好@user1093774我假设您使用的是Wix安装程序。如果是这样,为什么不使用Wix引导程序为您执行安装?还可以使用msiexec/l*v选项为快速回复创建一个log.Thx!:)我没有使用Wix安装程序。我项目中的另一位负责人决定了如何进行安装。我也不知道Wix。因此,目前Wix不是一个选项:(@user1093774)那么可能是因为您的安装没有在不同的用户下运行,没有足够的权限来执行安装。另一方面@user1093774为什么要使用自定义操作来安装msi?这就是您获得项目的方式吗?如果您不介意使用哪个安装程序?我尝试了您建议的方法d、 但是运气不好。当进程启动时,会出现一个messagebox,为我提供一些安装选项。对此messagebox,我唯一能做的就是点击“确定”按钮,然后关闭,而不安装任何内容:(.Hi@user1093774由于无法运行msi,因此出现消息框。您确定文件部署在正确的位置吗?调试CustomAction,然后复制并粘贴文件名值,转到cmd并运行msiexec/i'#粘贴文件名值'