Silent installation with target directory path as parameter

浪子不回头ぞ 提交于 2021-02-11 14:49:12

问题


In my C# app I run some setup in silent mode. the thing is that I want to enable to the user to choose the target installation directory but don't know how.

This is the silent install that works fine but installing in the default directory:

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

        }

But I need something like:

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

Here is the setup parameters:


回答1:


Change to:

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

If you run it directly from cmd that would be look like:

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


来源:https://stackoverflow.com/questions/50767450/silent-installation-with-target-directory-path-as-parameter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!