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

编程入门 行业动态 更新时间:2024-10-28 18:36:33
以目标目录路径作为参数的无提示安装(Silent installation with target directory path as parameter)

在我的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, . . . }

这里是设置参数:

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:

最满意答案

改成:

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

如果你直接从cmd运行它将看起来像:

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

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"

更多推荐

本文发布于:2023-07-30 23:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1340275.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   提示   参数   目标   目录

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!