Click here to Skip to main content
15,898,855 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have built a small application that reads text files and writes a new one. What I need to do now is schedule the application with windows scheduler and run it automatically at a certain time. Where do I start so application can run by itself? I have also read that I need arguments? It is a WinForm application so I have one button that needs to be clicked for the whole process to run.

What I have tried:

static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new DataReader());
        }


As far as I know this is where you list all the arguments to get the application going.
Posted
Updated 7-Feb-17 13:17pm
Comments
[no name] 7-Feb-17 18:51pm    
Why a Winform application when the task scheduler can't click the button to make your process run?
SmartDeveloping 8-Feb-17 10:19am    
because task scheduler can run the process for you overnight without you clicking on it.
[no name] 8-Feb-17 12:09pm    
And so what does that have anything to do with it? It can't push a button on your form so why on earth did you pick a Winform project to use?
SmartDeveloping 8-Feb-17 12:13pm    
Winform can still display the progress of what your application is doing. You can list the arguments of your button and create a auto switch which works with Windows Scheduler.
SmartDeveloping 8-Feb-17 12:19pm    
You should read the articles posted below. It will help you understand.

1 solution

Change it to be a console application run by the scheduler (no button - just do it) or set it up as a windows service.
You can use command line arguments or configuration files, etc. Give something a try and let us know if you have a specific problem

[EDIT] - Some articles you may find useful:
C#/.NET Command Line Arguments Parser[^]
Powerful and simple command line parsing in C#[^]
(There are several others - search for Command Line Parse in the search box at the top of this page)
Also:
Creating a Basic Windows Service in C#[^]
Simple Windows Service Sample[^]
Again - there are lots more articles here on Code Project on the subject
 
Share this answer
 
v2
Comments
SmartDeveloping 8-Feb-17 10:19am    
The command line arguments should be in the main method?
CHill60 8-Feb-17 12:05pm    
If you have a look at the code generated for you when you create a Console Application you will see
static void Main(string[] args)
so in once sense, yes - the command line arguments are passed to the main method - you can do what you like with them after that

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900