summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2014-06-20 11:53:28 +0200
committerKarsten Heimrich <karsten.heimrich@digia.com>2014-06-26 11:31:54 +0200
commit62704a673a4eb4c196efdec26bcf7c1da28fd2df (patch)
treeb138091d62cf9720be5e0251158da6be73cdc1cc
parent74a96de87ac7e9caf5c7951fa8fe493765111be7 (diff)
Don't try to elevate user rights if impossible
On Windows, if the user doesn't have administrative rights, we have to query the system policy for UAC. If UAC is not enabled, it is obviously not possible to use UAC to elevate the user's rights. Change-Id: Ieccf112efb50a6426277b32516ab58ca467a364e Reviewed-by: Sascha Cunz <sascha.cunz@gmail.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
-rw-r--r--src/libs/installer/adminauthorization_win.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libs/installer/adminauthorization_win.cpp b/src/libs/installer/adminauthorization_win.cpp
index 4d85ad980..f7ea464d1 100644
--- a/src/libs/installer/adminauthorization_win.cpp
+++ b/src/libs/installer/adminauthorization_win.cpp
@@ -44,6 +44,7 @@
#include <QDebug>
#include <QDir>
+#include <QSettings>
#include <qt_windows.h>
@@ -119,6 +120,19 @@ bool AdminAuthorization::execute(QWidget *, const QString &program, const QStrin
{
DeCoInitializer _;
+ // AdminAuthorization::execute uses UAC to ask for admin privileges. If the user is no
+ // administrator yet and the computer's policies are set to not use UAC (which is the case
+ // in some corporate networks), the call to execute() will simply succeed and not at all
+ // launch the child process. To avoid this, we detect this situation here and return early.
+ if (!hasAdminRights()) {
+ QLatin1String key("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
+ "Policies\\System");
+ QSettings registry(key, QSettings::NativeFormat);
+ const QVariant enableLUA = registry.value(QLatin1String("EnableLUA"));
+ if ((enableLUA.type() == QVariant::Int) && (enableLUA.toInt() == 0))
+ return false;
+ }
+
const QString file = QDir::toNativeSeparators(program);
const QString args = QInstaller::createCommandline(QString(), arguments);