Closed ghost closed 3 years ago
BootTrigger
is called one time after a system restarts. LogonTrigger
is called each time a user logs in if UserId
is set, or each time any user logs in if UserId
is not set/null
;
So now that you've explained to me those two, can you tell me where is the Startup trigger?
I believe BootTrigger
is what you're looking for. The triggers supported by this library are the same as those supported by Windows, no more, no less. For further information about the triggers, please see Microsoft's documentation.
@dahall According to the documentation:
The Task Scheduler service is started when the operating system is booted, and boot trigger tasks are set to start when the Task Scheduler service starts.
Now, I'm not sure whether they're referring that the scheduler service starts at boot time or when the OS starts.
Can you explain to me why when I've used the trigger BootTrigger
the startup program didn't start at any condition?
In all Windows documentation, "booted" refers to the OS. Windows services, like Task Scheduler, cannot run until the OS is available.
If BootTrigger
is not working, it is likely a permission problem. You can enable Task Scheduler logging through the Task Scheduler applet in Windows and then check the Event Viewer for the errors coming from Task Scheduler when trying to run your task.
@dahall How can I disable the "only if connected to power ac" option with your library? I want to test if this is what prevented the app from starting.
In all Windows documentation, "booted" refers to the OS. Windows services, like Task Scheduler, cannot run until the OS is available.
If
BootTrigger
is not working, it is likely a permission problem. You can enable Task Scheduler logging through the Task Scheduler applet in Windows and then check the Event Viewer for the errors coming from Task Scheduler when trying to run your task.
Can you redirect me to a resource where I can read more about this "permission" thing? I can barely find anything relevant on Google.
@dahall After reading a little about from the links, I think I need to enable "highest privilege". Can you tell me how to enable this in code? I can't find it in Settings.
TaskDefinition.Settings.Principal.RunLevel
Task Scheduler wasn't a goof fit after hours of frustrations, I went with writing to the Registry and it solved the problem. Thank you.
Ok, so I see there's
LogonTrigger
andBootTrigger
. But none of them solve the use-case I'm looking to solve.LogonTrigger
- Starts when the user is logged on, but not when the computer starts after a reboot.BootTrigger
- Does nothing (Starts during boot time??)So which Trigger actually starts the program upon Startup? doesn't matter if it's a reboot or a logon, any condition that Windows starts.