【问题标题】:How can I get NSIS to install and execute files from a temp directory?如何让 NSIS 从临时目录安装和执行文件?
【发布时间】:2011-07-04 10:00:59
【问题描述】:

我正在使用以下 NSIS 脚本:

Name "My app wrapper"
Outfile "MyAppSetup.exe"
InstallDir $TEMP\MyApp\Install
Function .onInit
SetSilent silent
FunctionEnd
Section ""
    SetOutPath $TEMP\MyApp\Install
    File installer.msi
    File setup.exe
    Exec setup.exe
SectionEnd

目的是安装程序会将这两个文件installer.msi 和setup.exe(它是安装prereqs 然后调用installer.msi 的引导程序)打包到MyApp Setup.exe 文件中。当 MyAppSetup.exe 运行时,它应该将 installer.msi 和 setup.exe 解压缩到 $Temp\MyApp\Install 目录,并且应该从该目录运行 setup.exe。

但是,当我从桌面运行 MyAppSetup 时,它会执行它在桌面上找到的 setup.exe 文件,我什至在 C:\Temp 中都看不到 MyApp\Install 目录。

我需要做什么才能让这个脚本将文件安装到正确的位置并执行正确的文件?

【问题讨论】:

    标签: nsis


    【解决方案1】:
    Section
    InitPluginsDir
    SetOutPath "$pluginsdir\MyApp\Install" ;It is better to put stuff in $pluginsdir, $temp is shared
    
    File installer.msi
    File setup.exe
    
    ExecWait '"$pluginsdir\MyApp\Install\setup.exe"' ;You should always use full paths and proper quotes
    
    SetOutPath $exedir ;Change current dir so $temp and $pluginsdir is not locked by our open handle
    SectionEnd
    

    【讨论】:

    • $pluginsdir 比 $temp 有什么好处? $pluginsdir 是什么?
    【解决方案2】:

    我不知道它是否能解决你的问题,但我会写:

    Exec $TEMP\MyApp\Instal\setup.exe
    

    您确定 $TEMP 指向 C:/Temp 吗?你检查了吗?

    【讨论】:

    • 啊,你是对的。它指向 AppData 中的某些内容。我现在看到那里的文件。它将文件放在正确的位置。我认为完整的路径也是解决方案。这是我之前尝试过的,但我认为由于某种原因我没有获得最新版本的安装程序。
    【解决方案3】:

    这是另一种方法

    Function .onInit
    
        InitPluginsDir
            File /oname=$PLUGINSDIR\test.exe "test.exe"
    
    FunctionEnd
    
    Section "Exec file" SecFile
    
        nsExec::Exec $PLUGINSDIR\test.exe
    
    SectionEnd
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-09
      • 2021-03-10
      • 2011-04-30
      • 1970-01-01
      • 1970-01-01
      • 2011-12-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多