【问题标题】:Silent installation with target directory path as parameter以目标目录路径为参数的静默安装
【发布时间】:2018-06-08 19:42:49
【问题描述】:

在我的 C# 应用程序中,我以静默模式运行一些设置。问题是我想让用户选择目标安装目录但不知道如何。

这是可以正常工作但安装在默认目录中的静默安装:

void RunSilentSetup(string executableFilePath)
        {

            ProcessStartInfo startInfo = new ProcessStartInfo()
            {
                CreateNoWindow = false,
                UseShellExecute = true,
                FileName = executableFilePath,
                WindowStyle = ProcessWindowStyle.Hidden,
                Arguments = "/s /v/qn"
            };
            using (Process exeProcess = Process.Start(startInfo))
            {
                exeProcess.WaitForExit();
                int exitcode = exeProcess.ExitCode;

                if (exitcode == 0)
                {
                    Console.WriteLine("Installation was successfully completed");
                                        }
                else
                    Console.WriteLine("one or more errors occurred during the installation");
            }

        }

但我需要类似的东西:

void RunSilentSetup(string executableFilePath, string targetDir)
{
 .
 .
 .
    Arguments = "/s /v/qn"+targetDir,
 .
 .
 .
 }

这里是设置参数:

【问题讨论】:

    标签: c# installshield


    【解决方案1】:

    改为:

    Arguments = "/s /v/qn /vINSTALLDIR=\"+targetDir+"\"",
    

    如果你直接从 cmd 运行它会是这样的:

    C:\someFolder\anotherFolder> setup /s /v/qn /vINSTALLDIR="D:\yourTargetDirectory"
    

    【讨论】:

      猜你喜欢
      • 2021-01-01
      • 1970-01-01
      • 2011-08-13
      • 2017-06-07
      • 1970-01-01
      • 2016-12-14
      • 1970-01-01
      • 2015-10-23
      • 1970-01-01
      相关资源
      最近更新 更多