Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch file running under Task Scheduler continues running after batch file completes

Tags:

batch-file

This is sort of a follow-up to my question earlier (link).

To test things out I made this simple batch file to ensure the Task Scheduler was properly executing the batch file:

cd "C:\Users\user\Desktop" echo. 2>test.txt 

So after the test.txt document is created on the desktop, the batch file should end but it continues to run:

Running Tasks List

Is there a way, either at the end of the batch file or a setting in the Task's Properties, to ensure that the cmd process quits?

Thanks!

like image 687
Anders Avatar asked Jul 26 '12 20:07

Anders


People also ask

Why does my scheduled task keep running?

Here, RUNNING means the task is running not the executable. This actually should not cause problem if you have the option "If the running task does not end when requested, force it to stop" enabled in Settings tab. In Settings tab, you can also enable the option "Stop the task if it runs longer than" to stop this task.

How do I run a batch file from Task Scheduler?

Step 1: Create a batch file you wish to run and place it under a folder where you have enough permissions, for example, under C drive. Step 2: Click on Start and under search, type in Task, and click open Task Scheduler. Step 3: Select Create Basic Task from the Action pane on the right of the window.


2 Answers

I ran into the exact same problem. However, I felt duped when I read what Trevor778 wrote in this post:

I had the same problem - the task worked but the status kept showing Running. One simple thing to try is click on the Task Scheduler Library in the left column. Click Action/Refresh. Presto. Status changed to Ready. That's all it was for me, the task ran fine, just the status didn't update. Hope this helps.

ref: https://social.technet.microsoft.com/Forums/en-US/2f6dc29c-3b8b-45f5-a2a7-53e076acc062/task-scheduler-scheduler-status-is-being-running-always?forum=winservergen

like image 165
Rob Avatar answered Oct 12 '22 22:10

Rob


you can add "exit" to last line of your script

cd "C:\Users\user\Desktop" echo. 2>test.txt exit 
like image 22
mathmut Avatar answered Oct 12 '22 21:10

mathmut