Files
pengcheng-exam-stu/src-tauri/windows/hooks.nsi
2025-10-20 15:08:37 +08:00

36 lines
1014 B
NSIS
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

!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