mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 02:06:36 +02:00
runner: show message box when restarting with different elevation fails (#1061)
Also make the message box appear on top of the settings window.
This commit is contained in:
committed by
GitHub
parent
a2a683d31e
commit
dad732b7e6
@@ -310,6 +310,33 @@ bool run_non_elevated(const std::wstring& file, const std::wstring& params) {
|
||||
return succedded;
|
||||
}
|
||||
|
||||
bool run_same_elevation(const std::wstring& file, const std::wstring& params) {
|
||||
auto executable_args = file;
|
||||
if (!params.empty()) {
|
||||
executable_args += L" " + params;
|
||||
}
|
||||
STARTUPINFO si = { 0 };
|
||||
PROCESS_INFORMATION pi = { 0 };
|
||||
auto succedded = CreateProcessW(file.c_str(),
|
||||
const_cast<LPWSTR>(executable_args.c_str()),
|
||||
nullptr,
|
||||
nullptr,
|
||||
FALSE,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&si,
|
||||
&pi);
|
||||
if (pi.hProcess) {
|
||||
CloseHandle(pi.hProcess);
|
||||
}
|
||||
if (pi.hThread) {
|
||||
CloseHandle(pi.hThread);
|
||||
}
|
||||
return succedded;
|
||||
}
|
||||
|
||||
|
||||
std::wstring get_process_path(HWND window) noexcept {
|
||||
const static std::wstring app_frame_host = L"ApplicationFrameHost.exe";
|
||||
DWORD pid{};
|
||||
|
||||
@@ -58,6 +58,9 @@ bool run_elevated(const std::wstring& file, const std::wstring& params);
|
||||
// Run command as non-elevated user, returns true if succeeded
|
||||
bool run_non_elevated(const std::wstring& file, const std::wstring& params);
|
||||
|
||||
// Run command with the same elevation, returns true if succedded
|
||||
bool run_same_elevation(const std::wstring& file, const std::wstring& params);
|
||||
|
||||
// Get the executable path or module name for modern apps
|
||||
std::wstring get_process_path(DWORD pid) noexcept;
|
||||
// Get the executable path or module name for modern apps
|
||||
|
||||
Reference in New Issue
Block a user