Link to home
Start Free TrialLog in
Avatar of gilweber3
gilweber3Flag for United States of America

asked on

How to run an C# application as an schedule Task

I have an C# application that is ran daily at 8:00am, where the user has to click the Run Gain Loss button on the form. I've attached a screenshot of the form. I'm looking for a solution where the application would run and the Run Gain Loss button is click automatically daily at 8:00am. I know I can setup a scheduled task to run the C# application at 8:00am but how do I execute the Run Gain Loss button? Any ideals on how I can get this application to run automatically, maybe some 3rd party software to click the Run Gain Loss button. Again, any ideals would much appeciated.

Thanks in Advance
ASKER CERTIFIED SOLUTION
Avatar of OriNetworks
OriNetworks

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kimputer
Kimputer

Usually I use AutoHotkey for these things. Please note the caveat, the screen has to be on and logged in. Therefore, it's better to get it running without the button (will take the original developer 4 seconds of work), that way the job always runs (even when you're not logged on)
I wouldn't rely on something to click a button. What if you redesign and the button moves? It will stop working.

Instead, have the code behind the button callable from elsewhere then the button and pass a parameter to your application to run your new method.

Check http://emoreau.com/Entries/Articles/2008/11/Passing-arguments-to-an-application-startup.aspx
Do you have the source code for this application?  That's not clear from the description.  If yes, then I'd go with Eric's suggestion and pass a parameter to the app so you 'll know to run the code associated with the button click.

Depending on what the app does, it might be possible to re-design it so all the work gets done from within program.cs without ever showing a form.