| Index: base/process/launch_win.cc
|
| diff --git a/base/process/launch_win.cc b/base/process/launch_win.cc
|
| index da913efba749089592644c627c2dc226dbfa6182..ea24e47d9e5e0148dbda307a3b067ec7d66fde80 100644
|
| --- a/base/process/launch_win.cc
|
| +++ b/base/process/launch_win.cc
|
| @@ -9,6 +9,7 @@
|
| #include <windows.h>
|
| #include <userenv.h>
|
| #include <psapi.h>
|
| +#include <Shellapi.h>
|
|
|
| #include <ios>
|
|
|
| @@ -279,4 +280,39 @@ void RaiseProcessToHighPriority() {
|
| SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
|
| }
|
|
|
| +bool LaunchElevatedProcess(const CommandLine& cmdline,
|
| + const LaunchOptions& options,
|
| + ProcessHandle* process_handle) {
|
| + const std::wstring file = cmdline.GetProgram().value();
|
| + const std::wstring arguments = cmdline.GetArgumentsString();
|
| +
|
| + SHELLEXECUTEINFO shex_info = {0};
|
| + shex_info.cbSize = sizeof(shex_info);
|
| + shex_info.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| + shex_info.hwnd = GetActiveWindow();
|
| + shex_info.lpVerb = L"runas";
|
| + shex_info.lpFile = file.c_str();
|
| + shex_info.lpParameters = arguments.c_str();
|
| + shex_info.lpDirectory = NULL;
|
| + shex_info.nShow = options.start_hidden ? SW_HIDE : SW_SHOW;
|
| + shex_info.hInstApp = NULL;
|
| +
|
| + if (!ShellExecuteEx(&shex_info)) {
|
| + DPLOG(ERROR);
|
| + return false;
|
| + }
|
| +
|
| + if (options.wait)
|
| + WaitForSingleObject(shex_info.hProcess, INFINITE);
|
| +
|
| + // If the caller wants the process handle give it to them, otherwise just
|
| + // close it. Closing it does not terminate the process.
|
| + if (process_handle)
|
| + *process_handle = shex_info.hProcess;
|
| + else
|
| + CloseHandle(shex_info.hProcess);
|
| +
|
| + return true;
|
| +}
|
| +
|
| } // namespace base
|
|
|