我如何执行应用程序正确安装后......与争论?

问题描述 投票:-1回答:2

我安装EXE应解压本身在一个临时文件夹,然后在其中执行的应用程序(与通过参数),返回,再次删除临时文件夹。我如何写剧本NSI?

nsis
2个回答
1
投票

这听起来像你对我试图创建一个便携式的应用程序。便携式应用时总是会更好原作者增加了对它的支持,因为它可以正确处理注册表和其他配置文件。

如果你仍然想创建一个启动应用程序,你可以这样做:

OutFile "MyLauncher.exe"
RequestExecutionLevel User
SilentInstall Silent
SetCompressor LZMA

!include FileFunc.nsh
!insertmacro GetParameters

Section
${GetParameters} $1
InitPluginsDir
SetOutPath $PluginsDir
File "c:\myfiles\MyApp.exe"
File /r "c:\myfiles\otherfiles\*.*" ; If you need to include other files required by the application
ExecWait '"$PluginsDir\MyApp.exe" /param1 "pa ra m2" /param3 $1' $0 ; $1 contains the parameters passed to your launcher, remove it if you don't want to pass those arguments
SetErrorLevel $0
SetOutPath $Temp ; Don't lock $PluginsDir so it can be deleted automatically by the installer
SectionEnd

0
投票

回答我的问题。所需NSI脚本骨架应该是这样的:

# The name of the installer (arbitrary)
Name "hello"

# The name of the installation file
OutFile "hello.exe"

# where put the installation - other options would be $TEMP, etc.
InstallDir $DESKTOP

RequestExecutionLevel user         # no Windows UAC popup please!
SilentInstall silent               # completely silent install
SetCompressor /SOLID /FINAL lzma   # max compression for inst. file

# The stuff to install
Section ""
  SetOutPath $INSTDIR              # where to install (overwritable by user!)
  File /r D:\...\...               # where the install material lives
SectionEnd

# this function auto-runs after installation is fine
Function .onInstSuccess
  # parameter are passed through via $CMDLINE
  ExecWait '"$OUTDIR\hello.dist\hello.exe" $CMDLINE'
  RMDir /r "$OUTDIR\hello.dist"    # remove install folder again
FunctionEnd
© www.soinside.com 2019 - 2024. All rights reserved.