mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
Start PowerToys Run through the ActionRunner (#12043)
This commit is contained in:
parent
086394d455
commit
b42eb08ec6
@ -307,25 +307,17 @@ inline bool run_non_elevated(const std::wstring& file, const std::wstring& param
|
|||||||
|
|
||||||
inline bool RunNonElevatedEx(const std::wstring& file, const std::wstring& params)
|
inline bool RunNonElevatedEx(const std::wstring& file, const std::wstring& params)
|
||||||
{
|
{
|
||||||
bool failedToStart = false;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CoInitialize(nullptr);
|
CoInitialize(nullptr);
|
||||||
if (!ShellExecuteFromExplorer(file.c_str(), params.c_str()))
|
if (!ShellExecuteFromExplorer(file.c_str(), params.c_str()))
|
||||||
{
|
{
|
||||||
failedToStart = true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
failedToStart = true;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (failedToStart)
|
|
||||||
{
|
|
||||||
Logger::warn(L"Failed to delegate process creation. Try a fallback");
|
|
||||||
DWORD returnPid;
|
|
||||||
return run_non_elevated(file, params, &returnPid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -243,7 +243,18 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger::error(L"Failed to start the process");
|
Logger::warn(L"RunNonElevatedEx() failed. Trying fallback");
|
||||||
|
std::wstring action_runner_path = get_module_folderpath() + L"\\PowerToys.ActionRunner.exe";
|
||||||
|
std::wstring newParams = L"-run-non-elevated -target modules\\launcher\\PowerLauncher.exe " + params;
|
||||||
|
if (run_non_elevated(action_runner_path, newParams, nullptr))
|
||||||
|
{
|
||||||
|
processStarted = true;
|
||||||
|
Logger::trace("Started PowerToys Run Process");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger::warn("Failed to start PowerToys Run");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user