以目标目录路径作为参数的无提示安装 [英] Silent installation with target directory path as parameter

查看:45
本文介绍了以目标目录路径作为参数的无提示安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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,
 .
 .
 .
 }

以下是设置参数:

推荐答案

更改为:

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

如果直接从cmd运行它,则看起来像这样:

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

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

这篇关于以目标目录路径作为参数的无提示安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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