Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

Windows installer helper: a declined permission prompt starts the old version again (nothing changed)

islandmed20773015671c
diff --git a/src/core/SelfUpdate.cpp b/src/core/SelfUpdate.cpp
index e61a4b64..a0a31d5c 100644
--- a/src/core/SelfUpdate.cpp
+++ b/src/core/SelfUpdate.cpp
@@ -538,10 +538,12 @@ std::string windowsHelperScript(const Install& install, const Download& d, unsig
" Remove-Item -LiteralPath $staged -Force; exit 2 }\n";
if (!portable) {
// NSIS: /S silent, /D= the folder (last, unquoted). Windows asks for permission when the folder needs it.
- s += "$p = Start-Process -FilePath $staged -ArgumentList \"/S /D=$root\" -Wait -PassThru\n";
+ // Declining the permission prompt throws: the version that was there is started again, nothing changed.
+ s += "try { $p = Start-Process -FilePath $staged -ArgumentList \"/S /D=$root\" -Wait -PassThru; $code = $p.ExitCode }\n"
+ "catch { $code = -1 }\n";
s += "Remove-Item -LiteralPath $staged -Force -ErrorAction SilentlyContinue\n";
- s += "if ($p.ExitCode -ne 0) { exit 3 }\n";
- if (relaunch) s += "Start-Process -FilePath $exe\n";
+ if (relaunch) s += "if (Test-Path -LiteralPath $exe) { Start-Process -FilePath $exe }\n";
+ s += "if ($code -ne 0) { exit 3 }\n";
s += "Remove-Item -LiteralPath $PSCommandPath -Force -ErrorAction SilentlyContinue\n";
return s;
}
diff --git a/tests/test_self_update.cpp b/tests/test_self_update.cpp
index bb6323f8..d84b021b 100644
--- a/tests/test_self_update.cpp
+++ b/tests/test_self_update.cpp
@@ -490,6 +490,8 @@ TEST(self_update_windows_helper) {
const std::string i = windowsHelperScript(in, d, 1234, false);
CHECK(i.find("\"/S /D=$root\"") != std::string::npos && i.find("Get-FileHash") < i.find("Start-Process"));
CHECK(i.find("Start-Process -FilePath $exe") == std::string::npos); // Later: no relaunch
+ const std::string ir = windowsHelperScript(in, d, 1234, true);
+ CHECK(ir.find("catch { $code = -1 }") < ir.find("Start-Process -FilePath $exe")); // declined prompt: old one again
}
// --- Member builds (core/MemberBuilds.cpp) ---