代码之家  ›  专栏  ›  技术社区  ›  Flufy

以目标目录路径为参数的静默安装

  •  0
  • Flufy  · 技术社区  · 8 年前

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

    1 回复  |  直到 8 年前
        1
  •  2
  •   Nehorai Elbaz    8 年前

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

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