From 8c94335efc73c578e716a125eb8e348cb2f84f0c Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Sat, 9 Aug 2025 09:24:32 +1000 Subject: [PATCH 01/17] Add bundled VC++ installation Uses `BUILD_RESOURCES_DIR` env var to read the exe and include in NSIS installer bundle. Filename: vc_redist.x64.exe --- scripts/installer.nsh | 85 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/scripts/installer.nsh b/scripts/installer.nsh index 6bc3a7a05..39a66e949 100644 --- a/scripts/installer.nsh +++ b/scripts/installer.nsh @@ -1,5 +1,90 @@ !include 'LogicLib.nsh' +; Function to check if VC++ Runtime is installed +!ifndef BUILD_UNINSTALLER +Function checkVCRedist + ; Check primary registry location for x64 runtime + ClearErrors + SetRegView 64 + ReadRegDWORD $0 HKLM "SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed" + SetRegView 32 + + ; Return 1 if installed, 0 if not + ${If} ${Errors} + StrCpy $0 0 + ${EndIf} +FunctionEnd +!endif + +; Custom initialization macro - runs early in the installation process +!macro customInit + ; Save register state + Push $0 + Push $1 + Push $2 + + ; Check if VC++ Runtime is already installed + Call checkVCRedist + + ${If} $0 != 1 + ; Not installed - ask user if they want to install it + MessageBox MB_YESNO|MB_ICONINFORMATION \ + "ComfyUI Desktop requires Microsoft Visual C++ 2015-2022 Redistributable (x64) to function properly.$\r$\n$\r$\n\ + This component is not currently installed on your system.$\r$\n$\r$\n\ + Would you like to install it now?$\r$\n$\r$\n\ + Note: If you choose No, some features may not work correctly." \ + /SD IDYES IDYES InstallVCRedist IDNO SkipVCRedist + + InstallVCRedist: + ; Extract bundled VC++ redistributable to temp directory + DetailPrint "Extracting Microsoft Visual C++ Redistributable..." + + ; Copy bundled redistributable from build resources to temp + File /oname=$TEMP\vc_redist.x64.exe "${BUILD_RESOURCES_DIR}\vc_redist.x64.exe" + + ; Install it + DetailPrint "Installing Microsoft Visual C++ Redistributable..." + + ; Execute installer silently + ExecWait '"$TEMP\vc_redist.x64.exe" /install /quiet /norestart' $2 + + ; Check installation result + ${If} $2 != 0 + ; Installation failed but not critical - warn user + MessageBox MB_OK|MB_ICONEXCLAMATION \ + "Visual C++ Redistributable installation returned error code: $2$\r$\n$\r$\n\ + ComfyUI Desktop installation will continue, but some features may not work correctly.$\r$\n$\r$\n\ + You may need to install Visual C++ Redistributable manually from Microsoft's website." + ${Else} + ; Verify installation succeeded by checking registry again + Call checkVCRedist + ${If} $0 == 1 + DetailPrint "Visual C++ Redistributable installed successfully." + ${Else} + DetailPrint "Warning: Visual C++ Redistributable installation could not be verified." + ${EndIf} + ${EndIf} + + ; Clean up downloaded file + Delete "$TEMP\vc_redist.x64.exe" + Goto ContinueInstall + + SkipVCRedist: + ; User chose to skip - warn them + MessageBox MB_OK|MB_ICONEXCLAMATION \ + "Visual C++ Redistributable will not be installed.$\r$\n$\r$\n\ + Warning: ComfyUI Desktop may not function correctly without this component.$\r$\n$\r$\n\ + You can download it manually from:$\r$\n\ + https://aka.ms/vs/17/release/vc_redist.x64.exe" + ${EndIf} + + ContinueInstall: + ; Restore register state + Pop $2 + Pop $1 + Pop $0 +!macroend + ; The following is used to add the "/SD" flag to MessageBox so that the ; machine can restart if the uninstaller fails. !macro customUnInstallCheckCommon From 7d9d58f6ddcbfb9fb89c3221d0523cec587d5f28 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 03:30:01 +1000 Subject: [PATCH 02/17] Add VC++ to installer - first pass --- .gitignore | 3 +++ package.json | 1 + scripts/downloadVCRedist.js | 30 ++++++++++++++++++++++++++++++ scripts/installer.nsh | 4 ++-- scripts/makeComfy.js | 1 + 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 scripts/downloadVCRedist.js diff --git a/.gitignore b/.gitignore index e0b9d8b7e..74c27d459 100644 --- a/.gitignore +++ b/.gitignore @@ -123,3 +123,6 @@ venv/ # UV assets/uv + +# Visual C++ Redistributable +assets/vcredist diff --git a/package.json b/package.json index e006747a4..494188622 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "clean:assets:git": "rimraf assets/ComfyUI/.git assets/ComfyUI/custom_nodes/ComfyUI-Manager/.git", "clean:slate": "yarn run clean & yarn run clean:assets & rimraf node_modules", "download:uv": "node scripts/downloadUV.js", + "download:vcredist": "node scripts/downloadVCRedist.js", "download-frontend": "node scripts/downloadFrontend.js", "make:frontend": "yarn run download-frontend", "format": "prettier --check .", diff --git a/scripts/downloadVCRedist.js b/scripts/downloadVCRedist.js new file mode 100644 index 000000000..57aa7355e --- /dev/null +++ b/scripts/downloadVCRedist.js @@ -0,0 +1,30 @@ +import axios from 'axios'; +import fs from 'fs-extra'; +import path from 'node:path'; + +async function downloadVCRedist() { + const vcRedistDir = path.join('./assets', 'vcredist'); + const vcRedistPath = path.join(vcRedistDir, 'vc_redist.x64.exe'); + + // Check if already downloaded + if (fs.existsSync(vcRedistPath)) { + console.log('< VC++ Redistributable already exists, skipping >'); + return; + } + + // Ensure directory exists + await fs.mkdir(vcRedistDir, { recursive: true }); + + console.log('Downloading Visual C++ Redistributable...'); + const downloadedFile = await axios({ + method: 'GET', + url: 'https://aka.ms/vs/17/release/vc_redist.x64.exe', + responseType: 'arraybuffer', + }); + + fs.writeFileSync(vcRedistPath, downloadedFile.data); + console.log('FINISHED DOWNLOADING VC++ REDISTRIBUTABLE'); +} + +// Download VC++ Redistributable +await downloadVCRedist(); diff --git a/scripts/installer.nsh b/scripts/installer.nsh index 39a66e949..eb69e5fdd 100644 --- a/scripts/installer.nsh +++ b/scripts/installer.nsh @@ -39,8 +39,8 @@ FunctionEnd ; Extract bundled VC++ redistributable to temp directory DetailPrint "Extracting Microsoft Visual C++ Redistributable..." - ; Copy bundled redistributable from build resources to temp - File /oname=$TEMP\vc_redist.x64.exe "${BUILD_RESOURCES_DIR}\vc_redist.x64.exe" + ; Copy bundled redistributable from assets to temp + File /oname=$TEMP\vc_redist.x64.exe "${BUILD_RESOURCES_DIR}\vcredist\vc_redist.x64.exe" ; Install it DetailPrint "Installing Microsoft Visual C++ Redistributable..." diff --git a/scripts/makeComfy.js b/scripts/makeComfy.js index 75b8272de..1a87e4dbd 100644 --- a/scripts/makeComfy.js +++ b/scripts/makeComfy.js @@ -21,6 +21,7 @@ execAndLog( ); execAndLog(`yarn run make:frontend`); execAndLog(`yarn run download:uv all`); +execAndLog(`yarn run download:vcredist`); execAndLog(`yarn run patch:core:frontend`); /** * Run a command and log the output. From 64db1424305457bff7a7bd07c675472a96b77920 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 04:14:16 +1000 Subject: [PATCH 03/17] Only download VC++ when publishing --- scripts/makeComfy.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/makeComfy.js b/scripts/makeComfy.js index 1a87e4dbd..71605e584 100644 --- a/scripts/makeComfy.js +++ b/scripts/makeComfy.js @@ -21,7 +21,16 @@ execAndLog( ); execAndLog(`yarn run make:frontend`); execAndLog(`yarn run download:uv all`); -execAndLog(`yarn run download:vcredist`); + +// Only download VC++ redistributable for production builds (ToDesktop or signed Windows builds) +// Check for PUBLISH=true which is set by ToDesktop builds and Windows signing builds +if (process.env.PUBLISH === 'true') { + console.log('Production build detected (PUBLISH=true) - downloading VC++ redistributable for Windows installer'); + execAndLog(`yarn run download:vcredist`); +} else { + console.log('Skipping VC++ redistributable download (PUBLISH != true)'); +} + execAndLog(`yarn run patch:core:frontend`); /** * Run a command and log the output. From 2ac921b884182a7dfde93772bf17d7314b18bfaf Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 05:31:55 +1000 Subject: [PATCH 04/17] Revert VC++ download via conditional build --- .gitignore | 3 --- package.json | 1 - scripts/downloadVCRedist.js | 30 ------------------------------ scripts/makeComfy.js | 10 ---------- 4 files changed, 44 deletions(-) delete mode 100644 scripts/downloadVCRedist.js diff --git a/.gitignore b/.gitignore index 74c27d459..e0b9d8b7e 100644 --- a/.gitignore +++ b/.gitignore @@ -123,6 +123,3 @@ venv/ # UV assets/uv - -# Visual C++ Redistributable -assets/vcredist diff --git a/package.json b/package.json index 494188622..e006747a4 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ "clean:assets:git": "rimraf assets/ComfyUI/.git assets/ComfyUI/custom_nodes/ComfyUI-Manager/.git", "clean:slate": "yarn run clean & yarn run clean:assets & rimraf node_modules", "download:uv": "node scripts/downloadUV.js", - "download:vcredist": "node scripts/downloadVCRedist.js", "download-frontend": "node scripts/downloadFrontend.js", "make:frontend": "yarn run download-frontend", "format": "prettier --check .", diff --git a/scripts/downloadVCRedist.js b/scripts/downloadVCRedist.js deleted file mode 100644 index 57aa7355e..000000000 --- a/scripts/downloadVCRedist.js +++ /dev/null @@ -1,30 +0,0 @@ -import axios from 'axios'; -import fs from 'fs-extra'; -import path from 'node:path'; - -async function downloadVCRedist() { - const vcRedistDir = path.join('./assets', 'vcredist'); - const vcRedistPath = path.join(vcRedistDir, 'vc_redist.x64.exe'); - - // Check if already downloaded - if (fs.existsSync(vcRedistPath)) { - console.log('< VC++ Redistributable already exists, skipping >'); - return; - } - - // Ensure directory exists - await fs.mkdir(vcRedistDir, { recursive: true }); - - console.log('Downloading Visual C++ Redistributable...'); - const downloadedFile = await axios({ - method: 'GET', - url: 'https://aka.ms/vs/17/release/vc_redist.x64.exe', - responseType: 'arraybuffer', - }); - - fs.writeFileSync(vcRedistPath, downloadedFile.data); - console.log('FINISHED DOWNLOADING VC++ REDISTRIBUTABLE'); -} - -// Download VC++ Redistributable -await downloadVCRedist(); diff --git a/scripts/makeComfy.js b/scripts/makeComfy.js index 71605e584..75b8272de 100644 --- a/scripts/makeComfy.js +++ b/scripts/makeComfy.js @@ -21,16 +21,6 @@ execAndLog( ); execAndLog(`yarn run make:frontend`); execAndLog(`yarn run download:uv all`); - -// Only download VC++ redistributable for production builds (ToDesktop or signed Windows builds) -// Check for PUBLISH=true which is set by ToDesktop builds and Windows signing builds -if (process.env.PUBLISH === 'true') { - console.log('Production build detected (PUBLISH=true) - downloading VC++ redistributable for Windows installer'); - execAndLog(`yarn run download:vcredist`); -} else { - console.log('Skipping VC++ redistributable download (PUBLISH != true)'); -} - execAndLog(`yarn run patch:core:frontend`); /** * Run a command and log the output. From 5eac5b2f83f8c6a8f000224e9997db4504c06ba2 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 05:32:26 +1000 Subject: [PATCH 05/17] Download VC++ in toDesktop script --- scripts/todesktop/beforeInstall.cjs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/scripts/todesktop/beforeInstall.cjs b/scripts/todesktop/beforeInstall.cjs index ccd678b18..741e2b06a 100644 --- a/scripts/todesktop/beforeInstall.cjs +++ b/scripts/todesktop/beforeInstall.cjs @@ -1,6 +1,32 @@ const { spawnSync } = require('child_process'); const path = require('path'); const os = require('os'); +const fs = require('fs'); +const axios = require('axios'); + +async function downloadVCRedist() { + const vcredistDir = path.join('build', 'vcredist'); + const vcredistPath = path.join(vcredistDir, 'vc_redist.x64.exe'); + + // Check if already downloaded + if (fs.existsSync(vcredistPath)) { + console.log('< VC++ Redistributable already exists, skipping >'); + return; + } + + // Ensure directory exists + await fs.promises.mkdir(vcredistDir, { recursive: true }); + + console.log('Downloading Visual C++ Redistributable...'); + const response = await axios({ + method: 'GET', + url: 'https://aka.ms/vs/17/release/vc_redist.x64.exe', + responseType: 'arraybuffer', + }); + + fs.writeFileSync(vcredistPath, response.data); + console.log('FINISHED DOWNLOADING VC++ REDISTRIBUTABLE'); +} module.exports = async ({ pkgJsonPath, pkgJson, appDir, hookName }) => { /** @@ -24,5 +50,8 @@ module.exports = async ({ pkgJsonPath, pkgJson, appDir, hookName }) => { shell: true, stdio: 'ignore', }); + + // Download VC++ redistributable for Windows installer + await downloadVCRedist(); } }; From 053019dd75cdd7186edf7c2a6aaa0b2c01c96dc7 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 05:53:12 +1000 Subject: [PATCH 06/17] Move VC++ download to afterPack hook --- scripts/todesktop/afterPack.cjs | 29 +++++++++++++++++++++++++++++ scripts/todesktop/beforeInstall.cjs | 29 ----------------------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/scripts/todesktop/afterPack.cjs b/scripts/todesktop/afterPack.cjs index 6dc227021..a01e5c058 100644 --- a/scripts/todesktop/afterPack.cjs +++ b/scripts/todesktop/afterPack.cjs @@ -2,6 +2,32 @@ const os = require('os'); const fs = require('fs/promises'); const path = require('path'); const { spawnSync } = require('child_process'); +const axios = require('axios'); +const fsSync = require('fs'); + +async function downloadVCRedist() { + const vcredistDir = path.join('build', 'vcredist'); + const vcredistPath = path.join(vcredistDir, 'vc_redist.x64.exe'); + + // Check if already downloaded + if (fsSync.existsSync(vcredistPath)) { + console.log('< VC++ Redistributable already exists, skipping >'); + return; + } + + // Ensure directory exists + await fs.mkdir(vcredistDir, { recursive: true }); + + console.log('Downloading Visual C++ Redistributable...'); + const response = await axios({ + method: 'GET', + url: 'https://aka.ms/vs/17/release/vc_redist.x64.exe', + responseType: 'arraybuffer', + }); + + fsSync.writeFileSync(vcredistPath, response.data); + console.log('FINISHED DOWNLOADING VC++ REDISTRIBUTABLE'); +} module.exports = async ({ appOutDir, packager, outDir }) => { /** @@ -43,6 +69,9 @@ module.exports = async ({ appOutDir, packager, outDir }) => { } if (os.platform() === 'win32') { + // Download VC++ redistributable for Windows installer + await downloadVCRedist(); + const appName = packager.appInfo.productFilename; const appPath = path.join(`${appOutDir}`, `${appName}.exe`); const mainPath = path.dirname(outDir); diff --git a/scripts/todesktop/beforeInstall.cjs b/scripts/todesktop/beforeInstall.cjs index 741e2b06a..ccd678b18 100644 --- a/scripts/todesktop/beforeInstall.cjs +++ b/scripts/todesktop/beforeInstall.cjs @@ -1,32 +1,6 @@ const { spawnSync } = require('child_process'); const path = require('path'); const os = require('os'); -const fs = require('fs'); -const axios = require('axios'); - -async function downloadVCRedist() { - const vcredistDir = path.join('build', 'vcredist'); - const vcredistPath = path.join(vcredistDir, 'vc_redist.x64.exe'); - - // Check if already downloaded - if (fs.existsSync(vcredistPath)) { - console.log('< VC++ Redistributable already exists, skipping >'); - return; - } - - // Ensure directory exists - await fs.promises.mkdir(vcredistDir, { recursive: true }); - - console.log('Downloading Visual C++ Redistributable...'); - const response = await axios({ - method: 'GET', - url: 'https://aka.ms/vs/17/release/vc_redist.x64.exe', - responseType: 'arraybuffer', - }); - - fs.writeFileSync(vcredistPath, response.data); - console.log('FINISHED DOWNLOADING VC++ REDISTRIBUTABLE'); -} module.exports = async ({ pkgJsonPath, pkgJson, appDir, hookName }) => { /** @@ -50,8 +24,5 @@ module.exports = async ({ pkgJsonPath, pkgJson, appDir, hookName }) => { shell: true, stdio: 'ignore', }); - - // Download VC++ redistributable for Windows installer - await downloadVCRedist(); } }; From 9b7d90731c18eee44b9f2048b164ccf0503d4ccd Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 06:12:26 +1000 Subject: [PATCH 07/17] Fix VC++ download path to use BUILD_RESOURCES_DIR --- scripts/todesktop/afterPack.cjs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/todesktop/afterPack.cjs b/scripts/todesktop/afterPack.cjs index a01e5c058..b1c9465f9 100644 --- a/scripts/todesktop/afterPack.cjs +++ b/scripts/todesktop/afterPack.cjs @@ -5,10 +5,20 @@ const { spawnSync } = require('child_process'); const axios = require('axios'); const fsSync = require('fs'); -async function downloadVCRedist() { - const vcredistDir = path.join('build', 'vcredist'); +async function downloadVCRedist(outDir) { + // outDir is something like C:\Users\VSSADM~1\AppData\Local\Temp\todesktop\241012ess7yxs0e\dist + // BUILD_RESOURCES_DIR is the parent's build directory + const mainPath = path.dirname(outDir); + const buildDir = path.join(mainPath, 'build'); + const vcredistDir = path.join(buildDir, 'vcredist'); const vcredistPath = path.join(vcredistDir, 'vc_redist.x64.exe'); + console.log('VC++ Redistributable paths:'); + console.log(' - outDir:', outDir); + console.log(' - mainPath:', mainPath); + console.log(' - buildDir:', buildDir); + console.log(' - vcredistPath:', vcredistPath); + // Check if already downloaded if (fsSync.existsSync(vcredistPath)) { console.log('< VC++ Redistributable already exists, skipping >'); @@ -26,7 +36,7 @@ async function downloadVCRedist() { }); fsSync.writeFileSync(vcredistPath, response.data); - console.log('FINISHED DOWNLOADING VC++ REDISTRIBUTABLE'); + console.log('FINISHED DOWNLOADING VC++ REDISTRIBUTABLE to:', vcredistPath); } module.exports = async ({ appOutDir, packager, outDir }) => { @@ -70,7 +80,7 @@ module.exports = async ({ appOutDir, packager, outDir }) => { if (os.platform() === 'win32') { // Download VC++ redistributable for Windows installer - await downloadVCRedist(); + await downloadVCRedist(outDir); const appName = packager.appInfo.productFilename; const appPath = path.join(`${appOutDir}`, `${appName}.exe`); From 24f9fb074c76067d5f0ab902309baf60f3502aa2 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 06:17:58 +1000 Subject: [PATCH 08/17] Add BUILD_RESOURCES_DIR env var logging --- scripts/todesktop/afterPack.cjs | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/todesktop/afterPack.cjs b/scripts/todesktop/afterPack.cjs index b1c9465f9..ef43d4a28 100644 --- a/scripts/todesktop/afterPack.cjs +++ b/scripts/todesktop/afterPack.cjs @@ -14,6 +14,7 @@ async function downloadVCRedist(outDir) { const vcredistPath = path.join(vcredistDir, 'vc_redist.x64.exe'); console.log('VC++ Redistributable paths:'); + console.log(' - BUILD_RESOURCES_DIR env:', process.env.BUILD_RESOURCES_DIR); console.log(' - outDir:', outDir); console.log(' - mainPath:', mainPath); console.log(' - buildDir:', buildDir); From ddc34d2d235d0fca9a65860767999b00655dcfb9 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 06:46:21 +1000 Subject: [PATCH 09/17] Improve VC++ installer UX with banner and nsExec --- scripts/installer.nsh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/installer.nsh b/scripts/installer.nsh index eb69e5fdd..dd28e4fd7 100644 --- a/scripts/installer.nsh +++ b/scripts/installer.nsh @@ -36,6 +36,9 @@ FunctionEnd /SD IDYES IDYES InstallVCRedist IDNO SkipVCRedist InstallVCRedist: + ; Show progress message + Banner::show /NOUNLOAD "Installing Visual C++ Redistributable..." + ; Extract bundled VC++ redistributable to temp directory DetailPrint "Extracting Microsoft Visual C++ Redistributable..." @@ -44,9 +47,14 @@ FunctionEnd ; Install it DetailPrint "Installing Microsoft Visual C++ Redistributable..." + DetailPrint "Please wait, this may take a minute..." + + ; Use nsExec to run without console window and reduce flashing + nsExec::ExecToLog '"$TEMP\vc_redist.x64.exe" /install /quiet /norestart' + Pop $2 - ; Execute installer silently - ExecWait '"$TEMP\vc_redist.x64.exe" /install /quiet /norestart' $2 + ; Hide progress message + Banner::destroy ; Check installation result ${If} $2 != 0 From 0f28904dd09c3582eec1f83016fbe64e34a7b583 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 06:48:07 +1000 Subject: [PATCH 10/17] Remove trailing whitespace from blank lines --- scripts/installer.nsh | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/scripts/installer.nsh b/scripts/installer.nsh index dd28e4fd7..6479e5101 100644 --- a/scripts/installer.nsh +++ b/scripts/installer.nsh @@ -8,7 +8,7 @@ Function checkVCRedist SetRegView 64 ReadRegDWORD $0 HKLM "SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed" SetRegView 32 - + ; Return 1 if installed, 0 if not ${If} ${Errors} StrCpy $0 0 @@ -22,10 +22,10 @@ FunctionEnd Push $0 Push $1 Push $2 - + ; Check if VC++ Runtime is already installed Call checkVCRedist - + ${If} $0 != 1 ; Not installed - ask user if they want to install it MessageBox MB_YESNO|MB_ICONINFORMATION \ @@ -34,28 +34,27 @@ FunctionEnd Would you like to install it now?$\r$\n$\r$\n\ Note: If you choose No, some features may not work correctly." \ /SD IDYES IDYES InstallVCRedist IDNO SkipVCRedist - + InstallVCRedist: ; Show progress message Banner::show /NOUNLOAD "Installing Visual C++ Redistributable..." - + ; Extract bundled VC++ redistributable to temp directory DetailPrint "Extracting Microsoft Visual C++ Redistributable..." - + ; Copy bundled redistributable from assets to temp File /oname=$TEMP\vc_redist.x64.exe "${BUILD_RESOURCES_DIR}\vcredist\vc_redist.x64.exe" - + ; Install it DetailPrint "Installing Microsoft Visual C++ Redistributable..." DetailPrint "Please wait, this may take a minute..." - + ; Use nsExec to run without console window and reduce flashing nsExec::ExecToLog '"$TEMP\vc_redist.x64.exe" /install /quiet /norestart' Pop $2 - + ; Hide progress message Banner::destroy - ; Check installation result ${If} $2 != 0 ; Installation failed but not critical - warn user @@ -72,11 +71,11 @@ FunctionEnd DetailPrint "Warning: Visual C++ Redistributable installation could not be verified." ${EndIf} ${EndIf} - + ; Clean up downloaded file Delete "$TEMP\vc_redist.x64.exe" Goto ContinueInstall - + SkipVCRedist: ; User chose to skip - warn them MessageBox MB_OK|MB_ICONEXCLAMATION \ @@ -85,7 +84,7 @@ FunctionEnd You can download it manually from:$\r$\n\ https://aka.ms/vs/17/release/vc_redist.x64.exe" ${EndIf} - + ContinueInstall: ; Restore register state Pop $2 @@ -131,14 +130,14 @@ FunctionEnd StrCpy $prefix "base_path: " ; Space at the end is important to strip away correct number of letters StrLen $prefixLength $prefix StrCpy $prefixFirstLetter $prefix 1 - + StrCpy $R3 $R0 StrCpy $R0 -1 IntOp $R0 $R0 + 1 StrCpy $R2 $R3 1 $R0 StrCmp $R2 "" +2 StrCmp $R2 $R1 +2 -3 - + StrCpy $R0 -1 ${DoUntil} ${Errors} From bcc3f99d6547b41d83e7e34905de7bc82a8aa988 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 07:22:38 +1000 Subject: [PATCH 11/17] Refactor VC++ verification into reusable function --- scripts/installer.nsh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/scripts/installer.nsh b/scripts/installer.nsh index 6479e5101..8135be6dc 100644 --- a/scripts/installer.nsh +++ b/scripts/installer.nsh @@ -14,6 +14,21 @@ Function checkVCRedist StrCpy $0 0 ${EndIf} FunctionEnd + +; Function to verify VC++ installation and show appropriate message +Function verifyVCRedistInstallation + Call checkVCRedist + ${If} $0 == 1 + DetailPrint "Visual C++ Redistributable installed successfully." + ${Else} + ; Installation may have failed or was cancelled + MessageBox MB_OK|MB_ICONEXCLAMATION \ + "Visual C++ Redistributable installation could not be verified.$\r$\n$\r$\n\ + ComfyUI Desktop installation will continue, but some features may not work correctly.$\r$\n$\r$\n\ + You may need to install Visual C++ Redistributable manually from Microsoft's website." + DetailPrint "Warning: Visual C++ Redistributable installation could not be verified." + ${EndIf} +FunctionEnd !endif ; Custom initialization macro - runs early in the installation process @@ -63,13 +78,8 @@ FunctionEnd ComfyUI Desktop installation will continue, but some features may not work correctly.$\r$\n$\r$\n\ You may need to install Visual C++ Redistributable manually from Microsoft's website." ${Else} - ; Verify installation succeeded by checking registry again - Call checkVCRedist - ${If} $0 == 1 - DetailPrint "Visual C++ Redistributable installed successfully." - ${Else} - DetailPrint "Warning: Visual C++ Redistributable installation could not be verified." - ${EndIf} + ; Verify installation succeeded + Call verifyVCRedistInstallation ${EndIf} ; Clean up downloaded file From 8666c2d72a5fff985d8696a3169d9e636207487d Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 07:22:59 +1000 Subject: [PATCH 12/17] Use ExecShell with runas for proper UAC elevation --- scripts/installer.nsh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/scripts/installer.nsh b/scripts/installer.nsh index 8135be6dc..504d91a84 100644 --- a/scripts/installer.nsh +++ b/scripts/installer.nsh @@ -64,23 +64,27 @@ FunctionEnd DetailPrint "Installing Microsoft Visual C++ Redistributable..." DetailPrint "Please wait, this may take a minute..." - ; Use nsExec to run without console window and reduce flashing - nsExec::ExecToLog '"$TEMP\vc_redist.x64.exe" /install /quiet /norestart' - Pop $2 + ; Use ExecShellWait with proper verb to handle UAC elevation + ; "runas" verb ensures UAC prompt appears properly + !define VCREDIST_PARAMS "/install /quiet /norestart" + + ; Try to bring installer to front before launching VC++ + BringToFront + + ; Launch with runas to ensure UAC prompt is visible + ExecShell "runas" "$TEMP\vc_redist.x64.exe" "${VCREDIST_PARAMS}" SW_SHOWNORMAL + + ; Wait a moment for the process to start + Sleep 1000 + + ; Keep our installer visible + BringToFront ; Hide progress message Banner::destroy - ; Check installation result - ${If} $2 != 0 - ; Installation failed but not critical - warn user - MessageBox MB_OK|MB_ICONEXCLAMATION \ - "Visual C++ Redistributable installation returned error code: $2$\r$\n$\r$\n\ - ComfyUI Desktop installation will continue, but some features may not work correctly.$\r$\n$\r$\n\ - You may need to install Visual C++ Redistributable manually from Microsoft's website." - ${Else} - ; Verify installation succeeded - Call verifyVCRedistInstallation - ${EndIf} + + ; Verify installation succeeded + Call verifyVCRedistInstallation ; Clean up downloaded file Delete "$TEMP\vc_redist.x64.exe" From e2a6a4e1fe2bfe829d128a9ca83b830013e038bb Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 07:52:51 +1000 Subject: [PATCH 13/17] Use ExecShellWait to wait for VC++ redist exit --- scripts/installer.nsh | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/scripts/installer.nsh b/scripts/installer.nsh index 504d91a84..da0149ae8 100644 --- a/scripts/installer.nsh +++ b/scripts/installer.nsh @@ -64,21 +64,12 @@ FunctionEnd DetailPrint "Installing Microsoft Visual C++ Redistributable..." DetailPrint "Please wait, this may take a minute..." - ; Use ExecShellWait with proper verb to handle UAC elevation - ; "runas" verb ensures UAC prompt appears properly - !define VCREDIST_PARAMS "/install /quiet /norestart" - - ; Try to bring installer to front before launching VC++ - BringToFront - - ; Launch with runas to ensure UAC prompt is visible - ExecShell "runas" "$TEMP\vc_redist.x64.exe" "${VCREDIST_PARAMS}" SW_SHOWNORMAL - - ; Wait a moment for the process to start - Sleep 1000 - - ; Keep our installer visible - BringToFront + ; Use ExecShellWait to handle UAC properly AND wait for completion + ; This combines the benefits of ExecShell (proper UAC) with waiting + DetailPrint "Waiting for Visual C++ Redistributable installation to complete..." + + ; ExecShellWait with "open" verb (let Windows detect elevation need from manifest) + ExecShellWait "open" "$TEMP\vc_redist.x64.exe" "/install /quiet /norestart" SW_SHOW ; Hide progress message Banner::destroy From 717f29c3409b426535b8244cb1f0dba114f1d608 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 08:35:40 +1000 Subject: [PATCH 14/17] Fix regression in shell window visibility --- scripts/installer.nsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/installer.nsh b/scripts/installer.nsh index da0149ae8..fe87f7709 100644 --- a/scripts/installer.nsh +++ b/scripts/installer.nsh @@ -68,8 +68,8 @@ FunctionEnd ; This combines the benefits of ExecShell (proper UAC) with waiting DetailPrint "Waiting for Visual C++ Redistributable installation to complete..." - ; ExecShellWait with "open" verb (let Windows detect elevation need from manifest) - ExecShellWait "open" "$TEMP\vc_redist.x64.exe" "/install /quiet /norestart" SW_SHOW + ; ExecShellWait with "runas" verb for explicit UAC elevation + ExecShellWait "runas" "$TEMP\vc_redist.x64.exe" "/install /quiet /norestart" SW_SHOWNORMAL ; Hide progress message Banner::destroy From 9778c8a7dd3078932cdf3102f57a79af83441bb6 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 09:48:21 +1000 Subject: [PATCH 15/17] Remove debug logging from VC++ download function --- scripts/todesktop/afterPack.cjs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/scripts/todesktop/afterPack.cjs b/scripts/todesktop/afterPack.cjs index ef43d4a28..8ad0d5dc6 100644 --- a/scripts/todesktop/afterPack.cjs +++ b/scripts/todesktop/afterPack.cjs @@ -6,20 +6,12 @@ const axios = require('axios'); const fsSync = require('fs'); async function downloadVCRedist(outDir) { - // outDir is something like C:\Users\VSSADM~1\AppData\Local\Temp\todesktop\241012ess7yxs0e\dist // BUILD_RESOURCES_DIR is the parent's build directory const mainPath = path.dirname(outDir); const buildDir = path.join(mainPath, 'build'); const vcredistDir = path.join(buildDir, 'vcredist'); const vcredistPath = path.join(vcredistDir, 'vc_redist.x64.exe'); - console.log('VC++ Redistributable paths:'); - console.log(' - BUILD_RESOURCES_DIR env:', process.env.BUILD_RESOURCES_DIR); - console.log(' - outDir:', outDir); - console.log(' - mainPath:', mainPath); - console.log(' - buildDir:', buildDir); - console.log(' - vcredistPath:', vcredistPath); - // Check if already downloaded if (fsSync.existsSync(vcredistPath)) { console.log('< VC++ Redistributable already exists, skipping >'); @@ -37,7 +29,7 @@ async function downloadVCRedist(outDir) { }); fsSync.writeFileSync(vcredistPath, response.data); - console.log('FINISHED DOWNLOADING VC++ REDISTRIBUTABLE to:', vcredistPath); + console.log('FINISHED DOWNLOADING VC++ REDISTRIBUTABLE'); } module.exports = async ({ appOutDir, packager, outDir }) => { From 21bb6bc249b3e7e3915c4b5a83d09f2bee5e4fc5 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 09:49:18 +1000 Subject: [PATCH 16/17] Simplify VC++ redistributable path construction --- scripts/todesktop/afterPack.cjs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/todesktop/afterPack.cjs b/scripts/todesktop/afterPack.cjs index 8ad0d5dc6..92dbe2904 100644 --- a/scripts/todesktop/afterPack.cjs +++ b/scripts/todesktop/afterPack.cjs @@ -7,9 +7,7 @@ const fsSync = require('fs'); async function downloadVCRedist(outDir) { // BUILD_RESOURCES_DIR is the parent's build directory - const mainPath = path.dirname(outDir); - const buildDir = path.join(mainPath, 'build'); - const vcredistDir = path.join(buildDir, 'vcredist'); + const vcredistDir = path.join(path.dirname(outDir), 'build', 'vcredist'); const vcredistPath = path.join(vcredistDir, 'vc_redist.x64.exe'); // Check if already downloaded From 0859a38a2a7eda47a02a3ea34ed5a30d92c97f41 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 14 Aug 2025 09:50:59 +1000 Subject: [PATCH 17/17] nit --- scripts/todesktop/afterPack.cjs | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/todesktop/afterPack.cjs b/scripts/todesktop/afterPack.cjs index 92dbe2904..32c7d383a 100644 --- a/scripts/todesktop/afterPack.cjs +++ b/scripts/todesktop/afterPack.cjs @@ -6,7 +6,6 @@ const axios = require('axios'); const fsSync = require('fs'); async function downloadVCRedist(outDir) { - // BUILD_RESOURCES_DIR is the parent's build directory const vcredistDir = path.join(path.dirname(outDir), 'build', 'vcredist'); const vcredistPath = path.join(vcredistDir, 'vc_redist.x64.exe');