diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-15 22:58:02 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-15 22:58:02 +0000 |
commit | 3216aa820e40c3a99374961546b0030da375a164 (patch) | |
tree | ed9d4de68bbd3d0e202e7ec96c3911e48ed4d66a /chrome/installer/util/install_util.cc | |
parent | bfbafe26d2d97f378da686f2a64016ac25562c16 (diff) | |
download | chromium_src-3216aa820e40c3a99374961546b0030da375a164.zip chromium_src-3216aa820e40c3a99374961546b0030da375a164.tar.gz chromium_src-3216aa820e40c3a99374961546b0030da375a164.tar.bz2 |
While doing system level install on Vista, if installer is not running
as admin already, relaunch it as admin (that will bring up Vista
elevation dialog).
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3433 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/install_util.cc')
-rw-r--r-- | chrome/installer/util/install_util.cc | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index 032e5e8..29bc51d 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -7,7 +7,7 @@ #include "install_util.h" -#include <windows.h> +#include <shellapi.h> #include "base/logging.h" #include "base/registry.h" @@ -16,6 +16,28 @@ #include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/google_update_constants.h" +bool InstallUtil::ExecuteExeAsAdmin(const std::wstring& exe, + const std::wstring& params, + DWORD* exit_code) { + SHELLEXECUTEINFO info = {0}; + info.cbSize = sizeof(SHELLEXECUTEINFO); + info.fMask = SEE_MASK_NOCLOSEPROCESS; + info.lpVerb = L"runas"; + info.lpFile = exe.c_str(); + info.lpParameters = params.c_str(); + info.nShow = SW_SHOW; + if (::ShellExecuteEx(&info) == FALSE) + return false; + + ::WaitForSingleObject(info.hProcess, INFINITE); + DWORD ret_val = 0; + if (!::GetExitCodeProcess(info.hProcess, &ret_val)) + return false; + + if (exit_code) + *exit_code = ret_val; + return true; +} std::wstring InstallUtil::GetChromeUninstallCmd(bool system_install) { HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |