I made a program, which was supposed to run every night as a windows scheduled task, let's say the program is just one method, called Do_Task(). Usually you need to press a button to run the Do_Task() method, but In order for it to run as a scheduled task, I had to call the Do_Task() method in the form loading event. (Can't tell windows scheduler to press a button).
But here is the problem: when I install it by the end user, I want to have the option of either automatic (Do_Task() gets called from the from loading event), or Manuel (Do_Task() runs only from a button). In order to do testing and change settings in config file.
I tried to implement it via a check-box and an application property, to specify how the program should run the next time it runs. In the form loading event, I made an IF statement checking, if run auto is true then set application property run auto as true and run Do_Task(), etc etc.
But it didn't work, It kind of ignored me and always Ran on auto. What am I missing? I suspect (from other problems I encountered with this issue) that the form loading event is too late for these kind of stuff, so what is the earliest place you can issue commands to your program.