[PowerToys Run] run non-elevated when runner is elevated (#3451)

* run Launcher non-elevated

* Implemented acquiring PID of Launcher

Co-authored-by: ivan100sic <ivan100sic@gmail.com>
This commit is contained in:
Enrico Giordani
2020-05-21 19:44:32 +02:00
committed by GitHub
parent 582d1320a3
commit a856263081
5 changed files with 75 additions and 11 deletions

View File

@@ -461,7 +461,7 @@ bool run_elevated(const std::wstring& file, const std::wstring& params)
}
}
bool run_non_elevated(const std::wstring& file, const std::wstring& params)
bool run_non_elevated(const std::wstring& file, const std::wstring& params, DWORD* returnPid)
{
auto executable_args = L"\"" + file + L"\"";
if (!params.empty())
@@ -521,8 +521,14 @@ bool run_non_elevated(const std::wstring& file, const std::wstring& params)
nullptr,
&siex.StartupInfo,
&process_info);
if (process_info.hProcess)
{
if (returnPid)
{
*returnPid = GetProcessId(process_info.hProcess);
}
CloseHandle(process_info.hProcess);
}
if (process_info.hThread)