Batch File Hangs. How Can I Effectively End It?  

Page 1 of 2 12 LastLast

  1. Posts : 27
    Windows 10 build 1909
       #1

    Batch File Hangs. How Can I Effectively End It?


    My machine is on v1909 (OS Build 18363.535).

    I run a batch file each night to close my Outlook process in preparation for nightly backup. It is, in fact, a batch file located here: Closing Outlook via a (scheduled) script - HowTo-Outlook. The specific script I am running is closeoutlookfailsafe.vbs, and I execute it as a cscript out of the batch file.

    It does execute what it is supposed to do, which is closing down Outlook, but then the CMD window hangs open and, within Task Scheduler, the process status maintains as "Running" indefinitely, until the machine shuts down after executing the backup process.

    I've been looking around for a way to gracefully end the batch process in such a way that the CMD window closes and the status resets to "Ready", but I am coming up dry. To be clear, the exact language in the batch file is:

    cscript.exe "C:\Users\[name]\Documents\Outlook Files\Close Outlook Scheduled Task Files\CloseOutlookFailsafe.vbs"

    Does anyone have any feel as to whether I can accomplish what I am looking to do here?
      My Computer


  2. Posts : 7,848
    windows 10
       #2

    Put a new last line
    exit
      My Computer


  3. Posts : 27
    Windows 10 build 1909
    Thread Starter
       #3

    Samuria said:
    Put a new last line
    exit
    If you mean like this:

    cscript.exe "C:\Users\Chuck\Documents\Outlook Files\Close Outlook Scheduled Task Files\CloseOutlookFailsafe.vbs" exit

    ... it half works. The CMD window does close after maybe ten or so seconds, but the status still maintains in Task Scheduler as "Running".

    I guess the $64 question is, is that a problem, or is it more like "no harm, no foul"? Because if it can maintain "Running" status without otherwise interfering with anything else, then I guess it's OK as is. Do you have a feel for that?
      My Computer


  4. Posts : 5,213
    Windows 11 Pro 64-bit
       #4

    You have to put the exit next line like below code:

    Code:
    cscript.exe "C:\Users\Chuck\Documents\Outlook Files\Close Outlook Scheduled Task Files\CloseOutlookFailsafe.vbs" 
    
    exit
      My Computer


  5. Posts : 27
    Windows 10 build 1909
    Thread Starter
       #5

    FreeBooter said:
    You have to put the exit next line like below code:

    Code:
    cscript.exe "C:\Users\Chuck\Documents\Outlook Files\Close Outlook Scheduled Task Files\CloseOutlookFailsafe.vbs" 
    
    exit
    Thanks for the suggestion, unfortunately it didn't make a difference. It works but it's still status of "Running" indefinitely.
      My Computer


  6. Posts : 5,213
    Windows 11 Pro 64-bit
       #6

    Can you post the batch script so i can have a look.
      My Computer


  7. Posts : 1,186
    W10-Pro 22H2
       #7

    As I also need to shut Outlook down before running a batch file-based backup, I stole your/their idea and tested it: my batch file (one line as yours) seems to exit fine. I put a pause at the end of it to see what TM showed when it was still running, and sure enough it held as expected. I did not have an exit command in the vbs bit. However, I have yet to test it under task scheduler...

    ...just tested it, and found the same as you: the task never seems to end. So I reverted my changes to what has been running fine for years, and the same occurred. I then re-instated the changes and set the task trigger so it ran in a scheduled way (as opposed to rt-click>run) and it ran fine (I create a log file, so I know when it has run). So I think you have found a bug in TS - the task may not still be running (I could not find it in Task Manager). I suggest you set it to run scheduled, and wait and see how it goes - I think you'll be OK!

    hth, Martin
    Last edited by mngerhold; 14 Jan 2020 at 13:27.
      My Computer


  8. Posts : 16,191
    Windows 10 Home x64 Version 22H2 Build 19045.3693
       #8

    It works but it's still status of "Running" indefinitely
    You are refreshing the view in Task scheduler? Otherwise it will just say Running until the cows come home.

    Denis
      My Computer


  9. Posts : 1,186
    W10-Pro 22H2
       #9

    well, I for one am prepared to admit to being a plonker, but why on earth does it need me to refresh it - it managed to say 'running' when I clicked 'run', is it too lazy to update when done? No need to answr, I am sure there is a good reason, eg with hundreds of tasks possible, activating at odd intervals, it would never stand still long enough for me to read anything. I feel sure I have met this before, now how to remember...
      My Computer


  10. Posts : 16,191
    Windows 10 Home x64 Version 22H2 Build 19045.3693
       #10

    Perhaps it was designed by a plonker.

    Denis
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 13:07.
Find Us




Windows 10 Forums