在我的C应用程序中,我在静默模式下运行一些设置。问题是我想让用户选择目标安装目录,但不知道如何选择。
这是静默安装,工作正常,但安装在默认目录中:
void runsilentsetup(string executablefilepath)
{
processStartInfo startInfo=新建processStartInfo()
{
createNowindow=false,
useShellExecute=真,
文件名=可执行文件路径,
windowstyle=processwindowstyle.hidden,
arguments=“/s/v/qn”
}(二)
使用(process exeprocess=process.start(startinfo))
{
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,
.
.
.
}
![]()