如何让 NSIS 安装并执行临时目录中的文件?

发布于 2024-10-19 09:07:32 字数 636 浏览 7 评论 0原文

我正在使用以下 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 (这是安装先决条件然后调用 installer.msi 的引导程序)打包到 MyApp Setup.exe 中文件。运行 MyAppSetup.exe 时,它​​应该将 installer.msi 和 setup.exe 提取到 $Temp\MyApp\Install 目录,并且应该从该目录运行 setup.exe。

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

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

I'm using the following NSIS script:

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

The intention is that the installer will wrap up those two files, installer.msi and setup.exe (which is a bootstrapper to install prereqs and then call installer.msi) into the MyApp Setup.exe file. When MyAppSetup.exe is run, it should extract installer.msi and setup.exe to the $Temp\MyApp\Install directory, and it should run setup.exe from that directory.

However, when I run MyAppSetup from the desktop, it executes a setup.exe file that it finds on the desktop, and I don't even see a MyApp\Install directory in C:\Temp.

What do I need to do to get this script to install the files to the right location and to execute the right file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓝梦月影 2024-10-26 09:07:32
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
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
清风不识月 2024-10-26 09:07:32

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

Exec $TEMP\MyApp\Instal\setup.exe

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

I don't know if it would solve your problem but I would write :

Exec $TEMP\MyApp\Instal\setup.exe

Are you sure that $TEMP is pointing to C:/Temp? Did you check it?

找个人就嫁了吧 2024-10-26 09:07:32

这是另一种方法

Function .onInit

    InitPluginsDir
        File /oname=$PLUGINSDIR\test.exe "test.exe"

FunctionEnd

Section "Exec file" SecFile

    nsExec::Exec $PLUGINSDIR\test.exe

SectionEnd

This is another way to do it

Function .onInit

    InitPluginsDir
        File /oname=$PLUGINSDIR\test.exe "test.exe"

FunctionEnd

Section "Exec file" SecFile

    nsExec::Exec $PLUGINSDIR\test.exe

SectionEnd
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文