summaryrefslogtreecommitdiffstats
path: root/chrome/installer/setup/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/installer/setup/main.cc')
-rw-r--r--chrome/installer/setup/main.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/chrome/installer/setup/main.cc b/chrome/installer/setup/main.cc
index 98b2191..4731b2f 100644
--- a/chrome/installer/setup/main.cc
+++ b/chrome/installer/setup/main.cc
@@ -454,6 +454,7 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
}
installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line,
+ const wchar_t* cmd_params,
const installer::Version* version,
bool system_install) {
LOG(INFO) << "Uninstalling Chome";
@@ -468,6 +469,26 @@ installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line,
bool remove_all = !cmd_line.HasSwitch(
installer_util::switches::kDoNotRemoveSharedItems);
bool force = cmd_line.HasSwitch(installer_util::switches::kForceUninstall);
+
+ // Check if we need admin rights to cleanup HKLM. Try to elevate - if it works
+ // exit from this process, if not just continue uninstalling in the current
+ // process itself.
+ if (remove_all &&
+ ShellUtil::AdminNeededForRegistryCleanup() &&
+ !IsUserAnAdmin() &&
+ (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) &&
+ !cmd_line.HasSwitch(installer_util::switches::kRunAsAdmin)) {
+ std::wstring exe = cmd_line.program();
+ std::wstring params(cmd_params);
+ // Append --run-as-admin flag to let the new instance of setup.exe know
+ // that we already tried to launch ourselves as admin.
+ params.append(L" --");
+ params.append(installer_util::switches::kRunAsAdmin);
+ DWORD exit_code = installer_util::UNKNOWN_STATUS;
+ if (InstallUtil::ExecuteExeAsAdmin(exe, params, &exit_code))
+ return static_cast<installer_util::InstallStatus>(exit_code);
+ }
+
return installer_setup::UninstallChrome(cmd_line.program(), system_install,
*version, remove_all, force);
}
@@ -595,6 +616,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
// If --uninstall option is given, uninstall chrome
if (parsed_command_line.HasSwitch(installer_util::switches::kUninstall)) {
install_status = UninstallChrome(parsed_command_line,
+ command_line,
installed_version.get(),
system_install);
// If --uninstall option is not specified, we assume it is install case.