From cc5c6ba5536e65cf5ab78854448d931c93d3c12a Mon Sep 17 00:00:00 2001 From: xxanqw Date: Wed, 26 Nov 2025 12:27:36 +0200 Subject: Add VC++ Redistributable 2022 installation to NSIS script --- .github/workflows/package-win.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package-win.yml b/.github/workflows/package-win.yml index 2b2f607..5a98fa8 100644 --- a/.github/workflows/package-win.yml +++ b/.github/workflows/package-win.yml @@ -82,6 +82,7 @@ jobs: !include "LogicLib.nsh" !include "x64.nsh" !include "WinVer.nsh" + !include "nsisdl.nsh" ; --- Helper Macros (MUST BE DEFINED BEFORE USE) --- !macro StrContains ResultVar Needle Haystack @@ -179,6 +180,10 @@ jobs: !define StrRep `!insertmacro StrRep` !define un.StrRep `!insertmacro un.StrRep` + ; --- VC++ Redistributable 2022 Download and Install --- + !define VC_REDIST_URL "https://aka.ms/vs/17/release/vc_redist.x64.exe" + !define VC_REDIST_EXE "$TEMP\vc_redist.x64.exe" + ; --- Main Script --- Name "Mikusays" OutFile "__OUTFILE__" @@ -207,7 +212,7 @@ jobs: Section "Install" SetOutPath "$INSTDIR" - + ; Architecture Detection ReadEnvStr $0 "PROCESSOR_ARCHITECTURE" ${If} $0 == "ARM64" @@ -225,6 +230,21 @@ jobs: WriteRegExpandStr HKCU "Environment" "Path" "$0;$INSTDIR" SendMessage ${HWND_BROADCAST} ${WM_SETTINGCHANGE} 0 "STR:Environment" /TIMEOUT=5000 ${EndIf} + + ; Install VC++ Redistributable 2022 (silent install) + MessageBox MB_OKCANCEL "This installer requires Microsoft Visual C++ Redistributable 2022.$\n$\nClick OK to download and install it now." IDOK download_vc + Abort "Microsoft Visual C++ Redistributable 2022 is required to run this application." + download_vc: + nsisdl::download /TIMEOUT=30000 "${VC_REDIST_URL}" "${VC_REDIST_EXE}" + Pop $0 + ${If} $0 == "success" + ExecWait '"${VC_REDIST_EXE}" /install /quiet /norestart' $1 + ${If} $1 != 0 + MessageBox MB_OK "Failed to install Microsoft Visual C++ Redistributable 2022 (Error $1).$\n$\nYou may need to install it manually from:$\n${VC_REDIST_URL}" + ${EndIf} + ${Else} + MessageBox MB_OK "Failed to download Microsoft Visual C++ Redistributable 2022.$\n$\nYou can install it manually from:$\n${VC_REDIST_URL}" + ${EndIf} SectionEnd Section "Uninstall" @@ -239,6 +259,9 @@ jobs: ${un.StrRep} $0 "$0" "$INSTDIR" "" WriteRegExpandStr HKCU "Environment" "Path" "$0" SendMessage ${HWND_BROADCAST} ${WM_SETTINGCHANGE} 0 "STR:Environment" /TIMEOUT=5000 + + ; Clean up VC++ Redistributable installer if it exists + Delete "${VC_REDIST_EXE}" SectionEnd '@ -- cgit v1.3-2-g0d8e