-3

I have a long-running .exe that I would like executed at 1:30am the morning after a user clicks a button on a webpage. It has two args and will be run infrequently. How do you create a one time scheduled task to run an executable with two args? Thanks!

EDIT: The user clicks a button that enables the .exe to run at 1:30am.

This question is different. I am wanting to know how to CODE the scheduling of a task.

rcurrydev
  • 45
  • 1
  • 10
  • Assuming from "exe" that it is Windows, you can just schedule it with Windows Task Scheduler, but it is unclear what you mean by "after a user clicks a button on a webpage". So, should it run after a user clicks or overnight? – Yeldar Kurmangaliyev Dec 27 '18 at 15:40
  • If I understood right, you just have to execute the process by passing arguments with the exe path, when someone clicks on the button. – Marco Salerno Dec 27 '18 at 15:42
  • Insufficient information! please describe your technical environment and the busines s case in more detail – Siraf Dec 27 '18 at 15:44
  • @YeldarKurmangaliyev The .exe is a windows console app. I know that I need to schedule it with Windows Task Scheduler, but how do I schedule it via code? When the user clicks a button that enables the .exe to run at 1:30am. – rcurrydev Dec 27 '18 at 20:26
  • @MarcoSalerno I know I need to pass the args, but I need to know how to code the scheduling of the task. – rcurrydev Dec 27 '18 at 20:27

1 Answers1

1

Your can use background scheduler libraries

I would suggest to use Hangifre, its easy to use and can do what you need easily

 BackgroundJob.Schedule(
    () => your action here,
    TimeSpan.FromDays(1));

TimeSpan.FromDays(1) => this you have to calcualte from the time the button is clicked to midnight, and pass the timespan in there, the task will be executed at midnight.

npo
  • 1,060
  • 8
  • 9
  • This is not what I asked for, nor can I use Hangfire in my project. – rcurrydev Dec 27 '18 at 20:30
  • Why not, you qustion asks how to schedule a task. Hangifre will run on your webstie. when user clicks a button you run the above code. In the "your action here" you start your long running exe file. Hangfire won't be inside your exe file it will be in your website – npo Dec 27 '18 at 20:34