36 lines
1014 B
NSIS
36 lines
1014 B
NSIS
!macro NSIS_HOOK_POSTINSTALL
|
||
# 1. 先确保主程序已释放
|
||
IfFileExists "$INSTDIR\ExamStudent.exe" +3
|
||
Abort
|
||
|
||
# 2. 检查.NET
|
||
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v8.0" "Release"
|
||
IntCmp $0 0 no_dotnet dotnet_installed no_dotnet
|
||
|
||
no_dotnet:
|
||
# 3. 防止安装程序提前退出
|
||
SetAutoClose false
|
||
BringToFront
|
||
|
||
# 去除弹窗
|
||
# MessageBox MB_OK|MB_ICONINFORMATION "需安装.NET 8.0"
|
||
|
||
# 4. 保持您的原始路径写法
|
||
InitPluginsDir
|
||
SetOutPath "$PLUGINSDIR"
|
||
File "${__FILEDIR__}\..\..\windowsdesktop-runtime-8.0.16-win-x64.exe"
|
||
|
||
# 5. 添加错误处理
|
||
ExecWait '"$PLUGINSDIR\windowsdesktop-runtime-8.0.16-win-x64.exe" /install /quiet /norestart' $0
|
||
${If} $0 != 0
|
||
# 去除弹窗
|
||
# MessageBox MB_ICONSTOP|MB_OK ".NET安装失败,错误码: $0"
|
||
Abort
|
||
${EndIf}
|
||
|
||
Delete "$PLUGINSDIR\windowsdesktop-runtime-8.0.16-win-x64.exe"
|
||
SetAutoClose true
|
||
|
||
dotnet_installed:
|
||
|
||
!macroend |