Does Robocopy Continue to Run if You X Out of Command Prompt

1st, rename the .bat file to something other than robocopy.bat.  Having the batch file named the same as the actual .exe/.com file it calls can really mess you up.

2nd, put the command "exit" into the .bat file after your robocopy command.  That should cause the task to actually close.

Was this post helpful? thumb_up thumb_down

Your command line looks fine to me.

And you can confirm it is "working" and successfully completing.  It is simply not terminating?

It is a scheduled task.  Who is the owner and executor of the task?

That is the only thing I can think of.  The system is unable to "kill" the task (or command prompt) when the task is done.

You could add a simple "exit" at the end of your batch file...  Have your tried that?

**EDIT **

Sean beat me to it...  by seconds.  ;-)

Was this post helpful? thumb_up thumb_down

Sean, yeah, the batch files are not named "robocopy" I am just using that as an example. My server names are obfuscated as well.

All, adding a second line with the word "exit" in the batch file did not change the situation.

Yes, the robocopy completes after about 4 seconds. Files sync'ed and log created. Just shows as "running" in task scheduler still.

Was this post helpful? thumb_up thumb_down

I would probably check directory access to the share or the target. Also you might check the user permissions that the task is running under. It just sound like access to the share or target directory (ies) may be getting denied. Scheduled Tasks for batch scripts after server 2008R2 were a little more difficult to get them to run consistently. Sometimes they fire and sometimes they just don't and it always seems to be an underlying permissions issue when they don't.

Only a suggestion. Good Luck.

*EDIT*

I totally missed that the batch was named robocopy ....Good catch by the other replies.

*RE-EDIT*

OK I RETRACT the above statement. Per the statement in the post. *edited* again, the batch files are not called "robocopy.bat" per the poster. Sorry to add to the confusion.

Was this post helpful? thumb_up thumb_down

What happens if you run your batch file manually?

Was this post helpful? thumb_up thumb_down

*edited* again, the batch files are not called "robocopy.bat"

Was this post helpful? thumb_up thumb_down

What happens if you run your batch file manually?

The same thing that happens when I run it in task scheduler, it works fine. The problem is not with the batch file running, the problem is that it stays "running" after it is done.

Was this post helpful? thumb_up thumb_down

Just for clarification: So the script actually completes the file copy, but remains as running after the task it completed?

Was this post helpful? thumb_up thumb_down

Gill B. wrote:

Just for clarification: So the script actually completes the file copy, but remains as running after the task it completed?

Yes, correct. Once I manually "end" it the last run result field says "The operation completed successfully."

I just need it to get out of the "running" state in task scheduler so it can be ready for the next schedule.

Was this post helpful? thumb_up thumb_down

SO when you run it manually, the cmd pops up then disappears?  I am just trying to see if something is hanging in the script or your task

Was this post helpful? thumb_up thumb_down

Ok. Thank you.

You might try adding

 schtasks /End /TN <name of your task>

to the end of the batch file.

Was this post helpful? thumb_up thumb_down

Also, have you tried putting a hard stop on the task in the task settings. Under settings tab. Stop the task if it runs longer than 2 hours? This is a preferred method over the above.

Was this post helpful? thumb_up thumb_down

So, I fixed it but I am too embarrassed to tell you what it was.

I am going to lunch, if someone can tell the thread what my dumb @ss was overlooking, I will award best answer.

Hint, it has been working correctly the whole time. What was I not doing in the console? Yes, it's Monday...

Was this post helpful? thumb_up thumb_down

Glad you got it working Chad. Now as to why it was not working. Don't know enough about what you did to get it working, but it was still running, so hip fire guess, but it gets us all from time to time: Did you not run it as administrator?

Was this post helpful? thumb_up thumb_down

You didn't hit refresh on the console ?

Was this post helpful? thumb_up thumb_down

Like I said. Case of the Mondays. Thanks everyone for trying to help...

Was this post helpful? thumb_up thumb_down

dominguezalwyet48.blogspot.com

Source: https://community.spiceworks.com/topic/1513659-robocopy-scheduled-task-works-but-stuck-as-running

0 Response to "Does Robocopy Continue to Run if You X Out of Command Prompt"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel