How to create Task Scheduler.
Step-by-step process.
what files should we create
Loading
How to create Task Scheduler.
Step-by-step process.
what files should we create
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sandhiya PriyaPosted Jan 2, 2026, 11:36 AM
Below is a simple, step-by-step guide to create a Task Scheduler in C# (.NET).
This explains what to create, which files are needed, and how it works.
Decide the type of Task Scheduler
There are two common approaches:
Option A – Windows Task Scheduler (Recommended)
Runs even after reboot
No need to keep app running
Best for production
Option B – Custom Scheduler (Timer / BackgroundService)
Runs only while app is running
Good for web apps or services
I’ll explain both, starting with the recommended one.
OPTION A: Windows Task Scheduler (Step-by-Step)
Step 1: Create a Console Application
Create a Console App (.NET Framework or .NET Core).
Files created:
Step 2: Write the Task Logic
This is the code that runs on schedule.
Program.cs
Build the project ? generates
TaskJob.exeStep 3: Create Task in Windows Task Scheduler
Open Task Scheduler
Click Create Basic Task
Name ?
MyDailyJobTrigger ? Daily / Hourly / On startup
Action ? Start a program
Browse ? select
TaskJob.exeStart in ? folder path of EXE
Finish
Task will now run automatically.
Files Required (Option A)
OPTION B: Custom Task Scheduler in C# (Timer Based)
Step 1: Create Console / Web App
Files:
Step 2: Create Job File
Job.cs
Step 3: Create Scheduler
Scheduler.cs
Step 4: Start Scheduler
Program.cs
Files Required (Option B)
App must be running for tasks to execute.
OPTION C: ASP.NET Core (Background Service)
Used in Web APIs.
Files:
Uses
BackgroundServiceorIHostedService.Which one should YOU use?
Summary (Quick Answer)
Best & safest ? Windows Task Scheduler
Create ? Console App (.exe)
Scheduler ? Windows Task Scheduler UI
Files needed ?
Program.cs?exeSatya KarkiPosted Feb 26, 2025, 11:19 AM
Hi,
You can use hangfire or Quartz.NET for .NET application. You can follow the article: https://www.csharp.com/article/scheduling-background-jobs-in-asp-net-core-using-quartz-net/
Tuhin PaulPosted Feb 26, 2025, 10:41 AM
Part -3
HLD overview:
Tuhin PaulPosted Feb 26, 2025, 10:41 AM
Part -2
Services/TaskRunnerService.cs
Program.cs
appsettings.json
Cron Schedule Support: Uses
Cronospackage for cron expressionsTask Types: Supports HTTP, SQL, and EXE tasks
Error Handling: Detailed execution history with error logs
Thread Safety: Proper scoping with DI containers
Configuration: JSON-based configuration for different task types
Install required packages:
Create database using EF Core migrations:
Create sample task:
Tuhin PaulPosted Feb 26, 2025, 10:32 AM
Part -1
Create these files in your .NET project:
Create these tables:
Models/ScheduledTask.cs
Models/ExecutionHistory.cs
Services/DatabaseContext.cs
Services/TaskSchedulerService.cs
Vinay SinghPosted Jan 29, 2025, 1:42 AM
Hi Subham,
Plesae refer the below link this may help you
https://www.c-sharpcorner.com/blogs/scheduling-in-asp-net-mvc-core
Muhammad Imran AnsariPosted Jan 28, 2025, 6:24 PM
Hi Shubham,
Creating a Task Scheduler in Windows to run a .NET Core application involves several steps. Below is a step-by-step guide to help you set it up:
Step 1: Create a .NET Core Application
1. Install .NET Core SDK: Ensure you have the .NET Core SDK installed on your machine. You can download it from the [official .NET website](https://dotnet.microsoft.com/download).
2. Create a New .NET Core Project:
- Open a command prompt or terminal.
- Run the following command to create a new console application:
- Navigate to the project directory:
3. Build the Project:
- Run the following command to build the project:
4. Publish the Project:
- Publish the project to create a self-contained executable:
- The published files will be located in the `bin/Release/netX.X/win-x64/publish` directory (replace `netX.X` with the appropriate .NET Core version).
Step 2: Create a Batch File to Run the .NET Core Application
1. Create a Batch File:
- Create a new text file in the publish directory and name it `RunMyScheduledTask.bat`.
- Open the batch file in a text editor and add the following content:
- Save and close the file.
Step 3: Set Up Task Scheduler
1. Open Task Scheduler:
- Press `Win + R`, type `taskschd.msc`, and press Enter to open the Task Scheduler.
2. Create a New Task:
- In the Task Scheduler, click on "Create Task" in the right-hand pane.
3. General Tab:
- Enter a name for the task (e.g., "RunMyScheduledTask").
- Optionally, provide a description.
- Select "Run whether user is logged on or not" and check "Do not store password".
4. Triggers Tab:
- Click on "New..." to create a new trigger.
- Set the trigger to your desired schedule (e.g., daily, weekly, at startup, etc.).
- Configure the start date, time, and recurrence as needed.
- Click "OK" to save the trigger.
5. Actions Tab:
- Click on "New..." to create a new action.
- Set "Action" to "Start a program".
- In the "Program/script" field, browse to the `RunMyScheduledTask.bat` file you created earlier.
- In the "Start in" field, enter the path to the directory containing the batch file (e.g., `C:\path\to\publish\directory`).
- Click "OK" to save the action.
6. Conditions Tab:
- Configure any additional conditions if needed (e.g., start the task only if the computer is idle).
7. Settings Tab:
- Configure any additional settings if needed (e.g., allow the task to be run on demand, stop the task if it runs longer than a specified time, etc.).
8. Save the Task:
- Click "OK" to save the task.
Step 4: Test the Task
1. Run the Task Manually:
- In the Task Scheduler, find your task in the list, right-click it, and select "Run" to test it.
- Check the output or logs to ensure the task runs as expected.
2. Check for Errors:
- If the task does not run as expected, check the "Last Run Result" in the Task Scheduler and review any error messages.
Files to Create
- .NET Core Application:The main executable and associated DLLs.
- Batch File (`RunMyScheduledTask.bat`): A script to run the .NET Core application.
By following these steps, you can successfully create a Task Scheduler task to run your .NET Core application on a specified schedule.