如何使用 NSIS 制作自解压 exe?
How to make self extracting exe using NSIS?
我想制作一个自解压的 exe(abcdInstaller.exe),它 运行 是另一个 exe(AppInstaller.apk,这是在我的电脑上安装 abcd.apk)。下面的脚本工作正常,但是当我 运行 abcdInstaller.exe 时,它还会将这两个文件提取到当前目录(从我 运行 宁此 exe 的位置)和 运行s AppInstaller.exe.
但我想要的是,用户只需单击 abcdInstaller.exe,abcdInstaller.exe 将 运行 AppInstaller.exe 在后台运行。
!include LogicLib.nsh
!include WinMessages.nsh
SilentInstall silent
RequestExecutionLevel user ;no elevation needed for this test
ShowInstDetails hide
# this will be the created executable archive
OutFile "abcdInstaller.exe"
InstallDir $EXEDIR
# the executable part
Section
# define the output path for the following files
SetOutPath $INSTDIR
# define what to install and place it in the output path...
# ...app...
File AppInstaller.exe
# ...and the library.
File abcd.apk
# run application
ExecShell "open" "AppInstaller.exe"
# done
SectionEnd
我尝试对 SetOutPath $INSTDIR 进行注释,但没有任何反应。
请给点建议。
我正在更新我的解决方案。
我正在将 exe 复制到临时文件夹,并在完成该过程后删除该文件夹。
!include LogicLib.nsh
!include WinMessages.nsh
SilentInstall silent
RequestExecutionLevel user ;no elevation needed for this test
ShowInstDetails hide
# this will be the created executable archive
OutFile "ABCD.exe"
InstallDir $EXEDIR
# the executable part
Section
# define the output path for the following files
SetOutPath $TEMP\ApkPath
# define what to install and place it in the output path...
# ...your app...
File AppInstaller.exe
# ...and the library.
File xyz.apk
# run your application
ExecWait "$TEMP\ApkPath\AppInstaller.exe"
SetOutPath $TEMP
RMDir /r $TEMP\ApkPath
# done
SectionEnd
您应该将 $PluginsDir 用于安装期间临时使用的文件:
SilentInstall silent
RequestExecutionLevel user
OutFile "Test.exe"
Section
InitPluginsDir
SetOutPath $PluginsDir
File "MyApp.exe"
ExecWait '"$PluginsDir\MyApp.exe"' ; Double quotes on the path
SetOutPath $Temp ; SetOutPath locks the directory and we don't want to lock $PluginsDir
SectionEnd
我想制作一个自解压的 exe(abcdInstaller.exe),它 运行 是另一个 exe(AppInstaller.apk,这是在我的电脑上安装 abcd.apk)。下面的脚本工作正常,但是当我 运行 abcdInstaller.exe 时,它还会将这两个文件提取到当前目录(从我 运行 宁此 exe 的位置)和 运行s AppInstaller.exe.
但我想要的是,用户只需单击 abcdInstaller.exe,abcdInstaller.exe 将 运行 AppInstaller.exe 在后台运行。
!include LogicLib.nsh
!include WinMessages.nsh
SilentInstall silent
RequestExecutionLevel user ;no elevation needed for this test
ShowInstDetails hide
# this will be the created executable archive
OutFile "abcdInstaller.exe"
InstallDir $EXEDIR
# the executable part
Section
# define the output path for the following files
SetOutPath $INSTDIR
# define what to install and place it in the output path...
# ...app...
File AppInstaller.exe
# ...and the library.
File abcd.apk
# run application
ExecShell "open" "AppInstaller.exe"
# done
SectionEnd
我尝试对 SetOutPath $INSTDIR 进行注释,但没有任何反应。
请给点建议。
我正在更新我的解决方案。
我正在将 exe 复制到临时文件夹,并在完成该过程后删除该文件夹。
!include LogicLib.nsh
!include WinMessages.nsh
SilentInstall silent
RequestExecutionLevel user ;no elevation needed for this test
ShowInstDetails hide
# this will be the created executable archive
OutFile "ABCD.exe"
InstallDir $EXEDIR
# the executable part
Section
# define the output path for the following files
SetOutPath $TEMP\ApkPath
# define what to install and place it in the output path...
# ...your app...
File AppInstaller.exe
# ...and the library.
File xyz.apk
# run your application
ExecWait "$TEMP\ApkPath\AppInstaller.exe"
SetOutPath $TEMP
RMDir /r $TEMP\ApkPath
# done
SectionEnd
您应该将 $PluginsDir 用于安装期间临时使用的文件:
SilentInstall silent
RequestExecutionLevel user
OutFile "Test.exe"
Section
InitPluginsDir
SetOutPath $PluginsDir
File "MyApp.exe"
ExecWait '"$PluginsDir\MyApp.exe"' ; Double quotes on the path
SetOutPath $Temp ; SetOutPath locks the directory and we don't want to lock $PluginsDir
SectionEnd