Windows 10: bat job started by Task Scheduler does not pause

Discus and support bat job started by Task Scheduler does not pause in Windows 10 Support to solve the problem; In the last week or so all bat jobs started by Task Scheduler have not paused. Previously, I would find a black CMD window open, waiting for me to hit... Discussion in 'Windows 10 Support' started by Old Professor, Jun 5, 2017.

  1. bat job started by Task Scheduler does not pause


    In the last week or so all bat jobs started by Task Scheduler have not paused. Previously, I would find a black CMD window open, waiting for me to hit return to close the window. The following test indicates that the bat job ran, but it did not pause.
    TEST.BAT
    time /T > c:\bat\test.logecho "--------------- starting test" >> c:\bat\test.logtime /T echo "-------------- finished test" >> c:\bat\test.logtime /T >> c:\bat\test.logpause

    TEST.LOG
    03:40 PM"--------------- starting test" "-------------- finished test" 03:40 PM


    Obviously, the task was scheduled to run at 3:40 pm. My "real" bat job shows the same behavior. What happened?

    :)
     
    Old Professor, Jun 5, 2017
    #1

  2. How to run concurrent batch jobs in task scheduler

    Try copy pasting it please

    http://www.aanning.com/ajissues/Parallel_scheduled_tasks/ss1.jpg

    I had tried this. Make a bat file, which contains below :

    START CLEAR_PHOTOSBYDATE0.BAT

    START CLEAR_PHOTOSBYDATE1.BAT

    START CLEAR_PHOTOSBYDATE2.BAT

    Double click...runs great. Right click, run as administrator, and it can not find the files...it does this in Task Scheduler too. This tells me task scheduler runs as admin.

    My properties are as:

    http://www.aanning.com/ajissues/Parallel_scheduled_tasks/properties.jpg
     
    Janning197, Jun 5, 2017
    #2
  3. Task Scheduler

    In Windows 10 version 1703 the Task Schedule with a .bat file will start, but does not recognize a mapped drive. If I start the .bat file manually it works fine. Prior version had no problem.

    ***Post moved by the moderator to the appropriate forum category.***
     
    RichardCobb, Jun 5, 2017
    #3
  4. bat job started by Task Scheduler does not pause

    Hi Old Professor. Welcome to the TenForums @Old Professor

    I can't be 100% certain but there is this shift going on from Command Prompt to Powershell in Windows 10.

    I really see in Creators update V1703. To tell what version you are running, Windows key + R, type winver, enter.

    I don't believe Pause is a valid commend in Powershell.

    Not sure how you ran the test.bat but could I suggest you open a command prompt window and run your test.bat. Please ensure it is command prompt and not powershell that defaults to blue background.

    Does it pause?

    As well if you do Windows key + X is command prompt listed or powershell?

    Other members may have a better root cause.
     
    Caledon Ken, Jun 7, 2017
    #4
  5. I've got to admit that I think of cmd as a substitute for DOS. I have a bat job that works and I would like to continue using it. If I start test.bat by clicking on it manually, it opens a Command Prompt window and works just the same as it would have under DOS. Specifically, it does open a cmd window which does pause.
    But when I start test.bat from the Task Scheduler, it appears that you are correct in that it runs in Powershell, which does not create a command prompt window. I run my "real" batch job, let's call it overnight.bat, at 3 am and find it useful to have the command prompt window open and paused waiting for me in the morning. How can I force the Task Scheduler to run overnight.bat in a Command Prompt window?
     
    Old Professor, Jun 8, 2017
    #5
  6. Samuria Win User
    Have you given your script a .bat or .cmd extention?

    For pause in PS use
    Write-Host "Press any key to continue …"
    $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

    Is it a typo in your script?

    c:\bat\test.logtime /T >> c:\bat\test.logpause
    should be c:\bat\test.logtime /T >> c:\bat\test.log
    pause
     
    Samuria, Jun 8, 2017
    #6
  7. Kari Win User
    Just to clarify this: Command Prompt is not going away, it is not dead, there's no such thing as "shift going on" to PowerShell.

    Both Command Prompt and PowerShell are integral parts of Windows 10, with different areas of use. The fact that in build 14971 PowerShell replaced Command Prompt in WIN + X menu (right click Start) does not mean anything else than just that: PowerShell replaced Command Prompt in WIN + X menu. Nothing else.

    Last December Computerworld tweeted this:

    Tweet



    — Twitter API (@user) date[/quote]

    Microsoft's Senior Program Manager Rich Turner (@richturn_ms) replied to that tweet:

    With FUD Rich Turner refers to "Fear, Uncertainty and Doubt", spreading invalid rumours as facts. Quite strong statement from a Senior Product Manager!

    He continues:

    ... and:

     
    Kari, Jun 8, 2017
    #7
  8. bat job started by Task Scheduler does not pause

    Thank you. Wasn't exactly sure where to check and as my sentence started I wasn't 100% certain. Point taken.

    Kari would you know why the OP's job run through the task scheduler is indeed now using Powershell as he reported rather than command prompt. Something changed.

    Thanks
     
    Caledon Ken, Jun 8, 2017
    #8
  9. Kari Win User
    To run Windows command line commands in PowerShell with parameters, switches and arguments, add cmd /c in front of the the command and place command in quotes (single or double quotes, as you prefer).

    An example. To change your default operating system's display name to W10 PRO x64 in boot menu on dual boot system, in an elevated Command Prompt you would use the following command:

    bcdedit /set {default} description "W10 PRO x64"

    To use same command in an elevated PowerShell, you would need to use following command with command line (in single quotes):

    cmd /c 'bcdedit /set {default} description "W10 PRO x64"'

    ... or the same but command line in double quotes:

    cmd /c "bcdedit /set {default} description "W10 PRO x64""

    To be sure your batch file is always run in Command Prompt mode, add cmd /c in front of every command line in batch file, adding single or double quotes around the command itself as told above. The cmd/c prefix tells system that command line that follows in quotes must be run in Command Prompt mode, regardless if it is launched from Command Prompt or PowerShell.
     
    Kari, Jun 8, 2017
    #9
  10. If I understand you correctly, this would be the syntax for the OP's batch command:

    cmd /c "c:\bat\test.logtime /T >> c:\bat\test.log"

    And would execute properly from either Command Prompt OR Powershell?
     
    Wiley Coyote, Jun 8, 2017
    #10
  11. Kari Win User
    Yes and no *Wink

    OP's original post clearly has the batch file wrong typed due missing line breaks.

    If we look that test batch with added line breaks, as it should be, it looks like this:

    Code: time /T > c:\bat\test.log echo "--------------- starting test" >> c:\bat\test.log echo "-------------- finished test" >> c:\bat\test.log time /T >> c:\bat\test.log pause[/quote]
    To be sure this will be run in Command Prompt mode, it would need to be edited like this:

    Code: cmd /c time /T > c:\bat\test.log cmd /c echo "--------------- starting test" >> c:\bat\test.log cmd /c echo "-------------- finished test" >> c:\bat\test.log cmd /c time /T >> c:\bat\test.log cmd /c pause[/quote]
    The cmd /c prefix is usually only needed when running command line commands with parameters in PowerShell, but it does no harm and can be used also in Command Prompt. When the prefix is used, command will be run in Command Prompt regardless if it is started from Command Prompt, PowerShell or WIN + R prompt.
     
  12. Thank you Sir. You have a good day and weekend too.
     
    Wiley Coyote, Jun 8, 2017
    #12
  13. Kari Win User

    bat job started by Task Scheduler does not pause

    LOL! You too, have a good weekend!

    Just to complete this "Command Prompt / PowerShell 101", here's something you might not have known: You can run PowerShell in Command Prompt window, and Command Prompt in PowerShell window.

    When in PowerShell, just type cmd and press Enter to switch to Command Prompt Mode. To indicate which mode you are using, see the prompt (highlighted yellow); In PowerShell mode, the prompt starts with letters PS (#1 in screenshot below), in Command Prompt mode those letters are missing from prompt (#2). When you exit Command Prompt mode with command exit returning to PowerShell mode, letters PS are again shown at beginning of the prompt (#3):


    bat job started by Task Scheduler does not pause [​IMG]


    And vice versa; when in Command Prompt, you can switch to PowerShell mode with command powershell and switch back to Command Prompt mode with command exit. In Command Prompt mode the letters PS in prompt are not shown (#1 and #3 in screenshot), whereas they are shown in PowerShell mode (#2):


    bat job started by Task Scheduler does not pause [​IMG]
     
  14. The file I am starting with the Task Scheduler has a type extension "bat." If that isn't sufficient to cause it to run under Command interpreter and not Power Shell, can I add a qualifier in the Task Scheduler? I really don't want to edit every line of the bat file. Or maybe the Task Scheduler could start cmd and the actual bat file could be specified in the additional parameter?

    I produce a log file using commands like time /T > c:\bat\test.log. The time-date stamp on the log file is proof that the bat job ran when it was scheduled.

    To be sure this will be run in Command Prompt mode, it would need to be edited like this:

    Code: cmd /c time /T > c:\bat\test.log cmd /c echo "--------------- starting test" >> c:\bat\test.log cmd /c echo "-------------- finished test" >> c:\bat\test.log cmd /c time /T >> c:\bat\test.log cmd /c pause[/quote]
    The cmd /c prefix is usually only needed when running command line commands with parameters in PowerShell, but it does no harm and can be used also in Command Prompt. When the prefix is used, command will be run in Command Prompt regardless if it is started from Command Prompt, PowerShell or WIN + R prompt.

    Kari[/quote]
     
    Old Professor, Jun 18, 2017
    #14
  15. Kari Win User
    First, this issue of yours is interesting; I have never seen a batch file (.bat or .cmd) when run as a task to start PowerShell instead of Command Prompt.

    That being said, this should take care of that:


    bat job started by Task Scheduler does not pause [​IMG]


    Program: cmd, argument: /c MyBatchFile.bat

    When saved it looks like this:


    bat job started by Task Scheduler does not pause [​IMG]
     
Thema:

bat job started by Task Scheduler does not pause

Loading...
  1. bat job started by Task Scheduler does not pause - Similar Threads - bat job started

  2. Task scheduler is not running jobs properly

    in Windows 10 Gaming
    Task scheduler is not running jobs properly: I had set up multiple jobs in Task Scheduler which runs for every 15min time interval each and 4 jobs with difference of 2-3 min each one after one which took 15min- 2hr time to complete depending on jobbut it goes in running status for infinite times and could not end jobs...
  3. Task scheduler is not running jobs properly

    in Windows 10 Software and Apps
    Task scheduler is not running jobs properly: I had set up multiple jobs in Task Scheduler which runs for every 15min time interval each and 4 jobs with difference of 2-3 min each one after one which took 15min- 2hr time to complete depending on jobbut it goes in running status for infinite times and could not end jobs...
  4. Task scheduler is not running jobs properly

    in Windows 10 BSOD Crashes and Debugging
    Task scheduler is not running jobs properly: I had set up multiple jobs in Task Scheduler which runs for every 15min time interval each and 4 jobs with difference of 2-3 min each one after one which took 15min- 2hr time to complete depending on jobbut it goes in running status for infinite times and could not end jobs...
  5. Task Scheduler is not starting

    in Windows 10 BSOD Crashes and Debugging
    Task Scheduler is not starting: Whenever I try to start Task Scheduler, it always brings me to an error. It says, "The Task Scheduler service on Local Computer started and then stopped. Some services stop automatically if they are not in us by other services or programs. I need to start this, so I can...
  6. Scheduled Task Won't Launch Program with .bat File

    in Windows 10 Customization
    Scheduled Task Won't Launch Program with .bat File: I wrote a couple simple bat files to both shut down and launch Adobe Media Encoder on a Windows 10 machine. When I double click on them, both launch and execute flawlessly. However when I schedule a task and click to run them from the scheduled task, the status just shows...
  7. Start VM via bat file in Windows Task Scheduler

    in Windows 10 Virtualization
    Start VM via bat file in Windows Task Scheduler: I'm attempting to start a VM from a bat file with Windows 10 Task Scheduler. The bat by itself and the script via CMD execute correctly, though I cannot get it to run as a bat in Task Scheduler. I've tried different configurations, directly from a CMD, etc. Interesting...
  8. Parallel batch jobs in one scheduled task

    in Windows 10 Support
    Parallel batch jobs in one scheduled task: Parallel batch jobs in one scheduled task hi, This should be an easy answer. I want to create one scheduled task, it will be called "CLEAR_PHOTOSBYDATE", see attached pic or (approximate example, not literal job...yet)...
  9. Task Scheduler and Bat File Problem

    in Windows 10 Support
    Task Scheduler and Bat File Problem: Hi, Not sure which forum to post this in, but hopefully someone has some insight and can help me with this. I have a simple .bat file that stops my media server, creates an archive of a folder (for backup purposes), and then starts the media server again. It works...
  10. Task Scheduler Will Not Start

    in Windows 10 Support
    Task Scheduler Will Not Start: Hey everyone, Have an issue with task scheduler not stating which is causing issues with say Nvidia Geforce Experience not starting as it requires it to update. When I try to start it from services I get that error. [img] When I try to launch the task scheduler...