From e2e14bba2335d9ea0a1de60a318c21efa4d067ef Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 26 Nov 2021 00:03:14 +0800 Subject: Update main.lua --- xmake/actions/update/main.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/xmake/actions/update/main.lua b/xmake/actions/update/main.lua index ed403f47a..7437606fa 100644 --- a/xmake/actions/update/main.lua +++ b/xmake/actions/update/main.lua @@ -158,9 +158,17 @@ function _install(sourcedir) if os.isfile(win_installer_name) then -- /D sets the default installation directory ($INSTDIR), overriding InstallDir and InstallDirRegKey. It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces. Only absolute paths are supported. local params = ("/D=" .. os.programdir()):split("%s", { strict = true }) - local testfile = path.join(os.programdir(), "temp-install") - local no_admin = os.trycp(path.join(os.programdir(), "scripts", "run.vbs"), testfile) - os.tryrm(testfile) + local no_admin = try {function () return winos.registry_query("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\XMake;NoAdmin") end} + if no_admin == nil then + no_admin = try {function () return winos.registry_query("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\XMake;NoAdmin") end} + end + if no_admin ~= nil then + no_admin = tostring(value):lower() == "true" + else + local testfile = path.join(os.programdir(), "temp-install") + no_admin = os.trycp(path.join(os.programdir(), "scripts", "run.vbs"), testfile) + os.tryrm(testfile) + end if no_admin then table.insert(params, 1, "/NOADMIN") end -- need UAC? if winos:version():gt("winxp") then -- cgit v1.3.1