How do I run my c# program as a scheduled task

后端 未结 10 1313
南笙
南笙 2021-01-12 08:59

I am still pretty much new to c# so you will have to bear with me.

I have developed a windows form program which updates some SQL records as an end of day process fo

相关标签:
10条回答
  • 2021-01-12 09:40

    Take a look in the Timer class
    http://msdn.microsoft.com/en-us/library/system.timers.timer(v=vs.110).aspx

    0 讨论(0)
  • 2021-01-12 09:40

    Add reference: Microsoft.Win32.TaskScheduler
    then write this code:

    using (TaskService ts = new TaskService())
    Microsoft.Win32.TaskScheduler.Task task = ts.GetTask(TaskName); 
    task.Run(); //start
    task.Stop(); //End
    
    0 讨论(0)
  • 2021-01-12 09:42

    I have similar task to do making winforms as windows task. what i did is

    in windows task scheduler in the task tab,under Run put your exe and then /Auto,it will run as schedule.

    Example:winform.exe /Auto

    0 讨论(0)
  • 2021-01-12 09:43

    If I'm understanding your question correctly, this is how you could possibly proceed:

    • Best way to parse command line arguments in C#? -> check the answers and choose a library to process the args or write your own code to do so.
    • Create a scheduled task if those arguments are present by Creating Scheduled Tasks
    0 讨论(0)
提交回复
热议问题