在我的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,
.
.
.
}
以下是设置参数:
答案 0 :(得分:2)
更改为:
Arguments = "/s /v/qn /vINSTALLDIR=\"+targetDir+"\"",
如果直接从cmd运行它,它将如下所示:
C:\someFolder\anotherFolder> setup /s /v/qn /vINSTALLDIR="D:\yourTargetDirectory"