我正在尝试找出我的 NSIS 安装程序中所有的代码片段。片段如下:
nsExec::ExecToStack 'Dism.exe /Online /Enable-Feature /FeatureName:NetFx3'
Pop $0
${If} $0 != 0
Pop $0
Push ".NET 3.5 failed to install: $\n$0"
Call DetailPrintTS
StrCpy $Errors "$Errors Errors From .NET 3.5 install:$\n$0$\n$\n"
${EndIf}
所以我想把这个因素考虑到:
Function LoggedExec
Pop $0
Pop $1
nsExec::ExecToStack $0
Pop $0
${If} $0 != 0
Pop $0
Push "$1 failed to install: $\n$0"
Call DetailPrintTS
StrCpy $Errors "$Errors Errors From $1 install:$\n$0$\n$\n"
${EndIf}
FunctionEnd
然后按如下方式调用它:
Push 'Dism.exe /Online /Enable-Feature /FeatureName:NetFx3'
Push '.NET 3.5'
Call LoggedExec
请注意,DetailPrintTS 是我制作的另一个函数,它在 DetailPrint 中包含时间戳:
Function DetailPrintTS
Pop $7
${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6
DetailPrint "$4:$5:$6 -- $7$\n"
FunctionEnd