diff --git a/PowerEditor/src/MISC/Process/Processus.cpp b/PowerEditor/src/MISC/Process/Processus.cpp index a04cb0f7..9d161e79 100644 --- a/PowerEditor/src/MISC/Process/Processus.cpp +++ b/PowerEditor/src/MISC/Process/Processus.cpp @@ -30,19 +30,19 @@ #include "Processus.h" -void Process::run() const +void Process::run(bool isElevationRequired) const { - const TCHAR *opVerb = TEXT("open"); + const TCHAR *opVerb = isElevationRequired ? TEXT("runas") : TEXT("open"); ::ShellExecute(NULL, opVerb, _command.c_str(), _args.c_str(), _curDir.c_str(), SW_SHOWNORMAL); } -unsigned long Process::runSync() const +unsigned long Process::runSync(bool isElevationRequired) const { SHELLEXECUTEINFO ShExecInfo = { 0 }; ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; ShExecInfo.hwnd = NULL; - ShExecInfo.lpVerb = TEXT("open"); + ShExecInfo.lpVerb = isElevationRequired ? TEXT("runas") : TEXT("open"); ShExecInfo.lpFile = _command.c_str(); ShExecInfo.lpParameters = _args.c_str(); ShExecInfo.lpDirectory = _curDir.c_str(); diff --git a/PowerEditor/src/MISC/Process/Processus.h b/PowerEditor/src/MISC/Process/Processus.h index 42773f3e..025c3afd 100644 --- a/PowerEditor/src/MISC/Process/Processus.h +++ b/PowerEditor/src/MISC/Process/Processus.h @@ -39,8 +39,8 @@ public: Process(const TCHAR *cmd, const TCHAR *args, const TCHAR *cDir) :_command(cmd), _args(args), _curDir(cDir){} - void run() const; - unsigned long runSync() const; + void run(bool isElevationRequired = false) const; + unsigned long runSync(bool isElevationRequired = false) const; protected: generic_string _command; diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 1ca5deec..bf4a3096 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1854,7 +1854,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa if (!updaterFullPath.empty()) { Process updater(updaterFullPath.c_str(), pNppParam->getWingupParams().c_str(), pNppParam->getWingupDir().c_str()); - updater.run(); + updater.run(pNppParam->shouldDoUAC()); } } return TRUE; diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 0c8b3959..41815862 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -1052,6 +1052,9 @@ bool NppParameters::load() nppPluginRootParent = _pluginRootDir; PathAppend(_pluginRootDir, TEXT("plugins")); + + // For PluginAdmin to launch the wingup with UAC + setElevationRequired(true); } if (!PathFileExists(nppPluginRootParent.c_str())) diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 43a615a4..ba2d5513 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -1751,14 +1751,17 @@ private: generic_string _wingupFullPath; generic_string _wingupParams; generic_string _wingupDir; + bool _isElevationRequired = false; public: generic_string getWingupFullPath() const { return _wingupFullPath; }; generic_string getWingupParams() const { return _wingupParams; }; generic_string getWingupDir() const { return _wingupDir; }; + bool shouldDoUAC() const { return _isElevationRequired; }; void setWingupFullPath(const generic_string& val2set) { _wingupFullPath = val2set; }; void setWingupParams(const generic_string& val2set) { _wingupParams = val2set; }; void setWingupDir(const generic_string& val2set) { _wingupDir = val2set; }; + void setElevationRequired(bool val2set) { _isElevationRequired = val2set; }; private: void getLangKeywordsFromXmlTree();