mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
[updater] Do not start PowerToys from PowerToys.Update.exe (#25690)
* [updater] Do not start PowerToys from PowerToys.Update.exe PowerToys is already being started from the installer which is run by the updater * Revert version.props
This commit is contained in:
@@ -110,7 +110,7 @@ bool InstallNewVersionStage1(fs::path installer)
|
|||||||
{
|
{
|
||||||
// Detect if PT was running
|
// Detect if PT was running
|
||||||
const auto pt_main_window = FindWindowW(pt_tray_icon_window_class, nullptr);
|
const auto pt_main_window = FindWindowW(pt_tray_icon_window_class, nullptr);
|
||||||
const bool launch_powertoys = pt_main_window != nullptr;
|
|
||||||
if (pt_main_window != nullptr)
|
if (pt_main_window != nullptr)
|
||||||
{
|
{
|
||||||
SendMessageW(pt_main_window, WM_CLOSE, 0, 0);
|
SendMessageW(pt_main_window, WM_CLOSE, 0, 0);
|
||||||
@@ -119,10 +119,7 @@ bool InstallNewVersionStage1(fs::path installer)
|
|||||||
std::wstring arguments{ UPDATE_NOW_LAUNCH_STAGE2 };
|
std::wstring arguments{ UPDATE_NOW_LAUNCH_STAGE2 };
|
||||||
arguments += L" \"";
|
arguments += L" \"";
|
||||||
arguments += installer.c_str();
|
arguments += installer.c_str();
|
||||||
arguments += L"\" \"";
|
arguments += L"\"";
|
||||||
arguments += get_module_folderpath();
|
|
||||||
arguments += L"\" ";
|
|
||||||
arguments += launch_powertoys ? UPDATE_STAGE2_RESTART_PT : UPDATE_STAGE2_DONT_START_PT;
|
|
||||||
SHELLEXECUTEINFOW sei{ sizeof(sei) };
|
SHELLEXECUTEINFOW sei{ sizeof(sei) };
|
||||||
sei.fMask = { SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC };
|
sei.fMask = { SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC };
|
||||||
sei.lpFile = copy_in_temp->c_str();
|
sei.lpFile = copy_in_temp->c_str();
|
||||||
@@ -137,7 +134,7 @@ bool InstallNewVersionStage1(fs::path installer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstallNewVersionStage2(std::wstring installer_path, std::wstring_view install_path, bool launch_powertoys)
|
bool InstallNewVersionStage2(std::wstring installer_path)
|
||||||
{
|
{
|
||||||
std::transform(begin(installer_path), end(installer_path), begin(installer_path), ::towlower);
|
std::transform(begin(installer_path), end(installer_path), begin(installer_path), ::towlower);
|
||||||
|
|
||||||
@@ -181,18 +178,6 @@ bool InstallNewVersionStage2(std::wstring installer_path, std::wstring_view inst
|
|||||||
state.state = UpdateState::upToDate;
|
state.state = UpdateState::upToDate;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (launch_powertoys)
|
|
||||||
{
|
|
||||||
std::wstring new_pt_path{ install_path };
|
|
||||||
new_pt_path += L"\\PowerToys.exe";
|
|
||||||
SHELLEXECUTEINFOW sei{ sizeof(sei) };
|
|
||||||
sei.fMask = { SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC };
|
|
||||||
sei.lpFile = new_pt_path.c_str();
|
|
||||||
sei.nShow = SW_SHOWNORMAL;
|
|
||||||
sei.lpParameters = UPDATE_REPORT_SUCCESS;
|
|
||||||
return ShellExecuteExW(&sei) == TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +215,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
|
|||||||
else if (action == UPDATE_NOW_LAUNCH_STAGE2)
|
else if (action == UPDATE_NOW_LAUNCH_STAGE2)
|
||||||
{
|
{
|
||||||
using namespace std::string_view_literals;
|
using namespace std::string_view_literals;
|
||||||
const bool failed = !InstallNewVersionStage2(args[2], args[3], args[4] == std::wstring_view{ UPDATE_STAGE2_RESTART_PT });
|
const bool failed = !InstallNewVersionStage2(args[2]);
|
||||||
if (failed)
|
if (failed)
|
||||||
{
|
{
|
||||||
UpdateState::store([&](UpdateState& state) {
|
UpdateState::store([&](UpdateState& state) {
|
||||||
|
|||||||
Reference in New Issue
Block a user