deployment - 如何在 NSIS 脚本的文件中保存 DetailPrint 命令消息?

标签 deployment nsis

想法是以静默模式运行 NSIS 脚本到远程机器,一旦安装成功完成,然后将日志文件返回到主机。

我有很多 Detailprint显示脚本进度的命令消息。现在的问题是我如何将这些消息保存到日志文件中。我正在调查这个 http://nsis.sourceforge.net/Dump_log_to_file但它说它不会在静音模式下工作。

最佳答案

我使用这种方法来保存日志。我不知道这是否是最好的方法,但对我来说效果很好。

!ifndef DEBUG_MODE
  !define DEBUG_MODE true
!endif

!define LOGFILE "$TEMP\my_logfile.log"

!if ${DEBUG_MODE} == true
  !define DetailPrint '!insertmacro _debugMsg'
!else
  !define DetailPrint '!insertmacro _nodebugMsg'
!endif

!macro _debugMsg MSG
  push $3
  push $2
  push $1
  push $0
  push $R0

  strcpy $R0 "${MSG}"

  ClearErrors
  FileOpen $1 ${LOGFILE} a
  FileSeek $1 0 END
  IfErrors +8
  ${GetTime} "" "L" $0 $0 $0 $0 $0 $2 $3
  FileWrite $1 "$0:$2:$3$\t"
  FileWrite $1 "${__FUNCTION__}$\t"
  FileWrite $1 "$R0"
  FileWrite $1 "$\t(${__FILE__},${__FUNCTION__},${__LINE__})"
  FileWrite $1 "$\n"
  FileClose $1

  pop $R0
  pop $0
  pop $1
  pop $2
  pop $3
!macroend

!macro _nodebugMsg _MSG
  ;you can put here nothing or you can put the regular DetailPrint
  DetailPrint "${MSG}"
!macroend

之后你只需要找到并用 ${DetailPrint} 替换 DetailPrint

关于deployment - 如何在 NSIS 脚本的文件中保存 DetailPrint 命令消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9234402/

相关文章:

user-interface - 如何跳过 NSIS "components"页面?

nsis - 按下后退按钮时保留自定义页面上的数据

java - JBoss AS 5.1 部署失败 (org.jboss.deployers.spi.DeploymentException)

国家信息系统 |留言箱 |显示文本和变量

Git 推送到实时服务器

node.js - 从 github 在 azure 上部署默认 Angular 应用程序会出现错误

batch-file - 使用 NSIS 安装程序中的参数运行控制台应用程序

powershell - 安装其他安装程序?

node.js - 在 Azure 上持续部署 Nodejs 应用程序

react-native - 在外部网络上托管 Expo 应用程序?