By default when you create a new task DisallowStartIfOnBatteries and StartIfGoingOnBatteries are true, so that’s something to keep in mind if you are writing code that can be deployed on a laptop and you must have your scheduled task continue to run.

Quick side note, I personally think negative property names are hard to follow (DisallowStartIfOnBatteries). It’s hard to follow when it becomes a double negative. I think it would’ve been much better to name the property

AllowStartOnBatteries

Especially since it has nothing to do with starting the task when its not on batteries. It’s interesting that the UI control for this doesn’t use a double negative to display the context (even though the phrasing is logically inverse). Still, case in point