Windows Server 2008 Task Scheduler Job status shows running after job is done

I have a task that runs a .bat file to ftp files from one server to another.  It writes events to the Event log about the progress of the job.  The last event it writes is "Job Completed SUCCESSFULLY".

Following are the last lines of the .bat file.
      eventcreate /t information /id 107 /l application /d " Get DB Backup Job Completed SUCCESSFULLY."

      net use %1: /delete

The problem is that even though the processing of the bat file completes, the job status in Task Scheduler shows running and the next night when the task should run, it doesn't launch because its status is still Running.  

I am thinking about changing the trigger to end job if runs longer than 8 hours, but was wondering if anyone has seen this type of issue before.  The job runs under a local ID with admin privileges.  Sometimes it runs fine and ends other times it remains in a running status until I end it manually.

Any ideas?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gary ColtharpSr. Systems EngineerCommented:
Why do you not have an exit after your event creation?
BriantCAuthor Commented:
Because I always want to execute the net use %1: /delete command to unmap the source share drive.

I wonder if the net use /delete is prompting for a Y/N response sometimes.  I'll look to see if there is a noprompt option.
Gary ColtharpSr. Systems EngineerCommented:
I dont know of any Y/N that would occur on a net use /del.... you could try redirecting the output of the lines of your batch file to a log , ie; >>output.log .... then examining the end of it the next day to see if any errors were trapped.
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

BriantCAuthor Commented:
Good idea gcoltharp!  Below is the output in the .txt file.  

There are open files and/or incomplete directory searches pending on the connection to M:.

Is it OK to continue disconnecting and force them closed? (Y/N) [N]:

Do you know how I can script a response?  The files have already been copied over, compared, and deleted at this point.  It doesn't always hang, only sometimes.  Can I add /noprompt or something to force it to delete the connection everytime?
Gary ColtharpSr. Systems EngineerCommented:
Try adding /yes to the end

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
If that does not work, you can also try:

Echo yes | net use %1: /d

BriantCAuthor Commented:
Thanks gcoltharp!

Redirecting the output to the .txt file identified why the job was hanging and adding the /yes after the net use comand appears to have resolved the issue in my limited testing.
BriantCAuthor Commented:
Thanks also telczj9 for responding.

I will keep your suggestion in case I encounter the same type of hung state in the future.
Gary ColtharpSr. Systems EngineerCommented:
Awesome! Happy to help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.