首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用NSIS制作自解压缩执行程序?

如何使用NSIS制作自解压缩执行程序?
EN

Stack Overflow用户
提问于 2016-03-01 19:20:56
回答 2查看 1.2K关注 0票数 2

我想做一个自解压缩的exe(abcdInstaller.exe),它运行另一个exe(AppInstaller.apk,这是在我的pc上安装abcd.apk )。下面的脚本运行良好,但当我运行abcdInstaller.exe时,它也会在当前目录(从我运行这个exe的位置)提取这两个文件并运行AppInstaller.exe。

但是我想要的是,用户只需点击abcdInstaller.exe,abcdInstaller.exe就会在后台运行AppInstaller.exe,这将完成它的工作。

代码语言:javascript
复制
!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,但后来什么也没发生。

请给我一些建议。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-03-02 11:12:33

对于安装过程中临时使用的文件,您应该使用$PluginsDir:

代码语言:javascript
复制
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
票数 1
EN

Stack Overflow用户

发布于 2016-03-02 07:32:32

我在更新我的解决方案。

我正在将exe复制到临时文件夹,并在完成该过程后删除该文件夹。

代码语言:javascript
复制
!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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35731594

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档