mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
Sync run on startup with actual task scheduler (#14723)
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
// TODO: would be nice to get rid of these globals, since they're basically cached json settings
|
// TODO: would be nice to get rid of these globals, since they're basically cached json settings
|
||||||
static std::wstring settings_theme = L"system";
|
static std::wstring settings_theme = L"system";
|
||||||
|
static bool startup_disabled_manually = false;
|
||||||
static bool run_as_elevated = false;
|
static bool run_as_elevated = false;
|
||||||
static bool download_updates_automatically = true;
|
static bool download_updates_automatically = true;
|
||||||
|
|
||||||
@@ -91,7 +92,20 @@ void apply_general_settings(const json::JsonObject& general_configs, bool save)
|
|||||||
if (json::has(general_configs, L"startup", json::JsonValueType::Boolean))
|
if (json::has(general_configs, L"startup", json::JsonValueType::Boolean))
|
||||||
{
|
{
|
||||||
const bool startup = general_configs.GetNamedBoolean(L"startup");
|
const bool startup = general_configs.GetNamedBoolean(L"startup");
|
||||||
if (startup)
|
|
||||||
|
auto settings = get_general_settings();
|
||||||
|
static std::once_flag once_flag;
|
||||||
|
std::call_once(once_flag, [settings, startup, general_configs] {
|
||||||
|
if (json::has(general_configs, L"startup", json::JsonValueType::Boolean))
|
||||||
|
{
|
||||||
|
if (startup == true && settings.isStartupEnabled == false)
|
||||||
|
{
|
||||||
|
startup_disabled_manually = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (startup && !startup_disabled_manually)
|
||||||
{
|
{
|
||||||
if (is_process_elevated())
|
if (is_process_elevated())
|
||||||
{
|
{
|
||||||
@@ -117,6 +131,7 @@ void apply_general_settings(const json::JsonObject& general_configs, bool save)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete_auto_start_task_for_this_user();
|
delete_auto_start_task_for_this_user();
|
||||||
|
startup_disabled_manually = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (json::has(general_configs, L"enabled"))
|
if (json::has(general_configs, L"enabled"))
|
||||||
|
|||||||
@@ -404,6 +404,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
result = -1;
|
result = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save settings on closing
|
||||||
|
auto general_settings = load_general_settings();
|
||||||
|
apply_general_settings(general_settings);
|
||||||
|
|
||||||
// We need to release the mutexes to be able to restart the application
|
// We need to release the mutexes to be able to restart the application
|
||||||
if (msi_mutex)
|
if (msi_mutex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user