Search code examples
scheduled-taskswindows-task-scheduler

Create a task with task Scheduler to run cmd.exe with commands


I created a task with the task scheduler in windows 10 to open cmd.exe. it ran successfully like this

The output successfully achieved

But I need to run some commands every time it opens something like this

enter image description here

and automatically runs this command.

this is important that it opens a command prompt first and then runs the command inside the command prompt automatically.


Solution

  • Use /k flag. See cmd.exe /k switch.

    If you don't need console window to stay after commands completed use /c flag. You can read more about them with cmd /?