How can I force a scheduled .bat job to run in the foreground?

17,798

Solution 1

I actually found this answer over on StackOverflow.

In the Scheduled Task properties, under the 'Actions' tab, choose your action and click edit.

Under the program/script field, change this to cmd.

Under the add arguments field, change this to `/k "C:\path\to\job.bat".

This worked for me.

Solution 2

When you schedule the task, if you set it to run as the user that will be logged in at the time, It should run in the foreground. There is also a "Hidden" checkbox under the general tab. Ensure that is unchecked.

Share:
17,798

Related videos on Youtube

lonewookie
Author by

lonewookie

Updated on September 18, 2022

Comments

  • lonewookie
    lonewookie over 1 year

    I have a simple .bat that runs a PHP script at the same time every day.

    @echo ON
    php C:\path\to\script.php argument
    pause
    

    It runs fine when I double-click the .bat file. And I set up a scheduled task to run it everyday, but it runs in the background. No Command line window anywhere. I can see that it is indeed running.

    I would really like to be able to monitor this job as it runs.

    How can I force this to run in a command-line window in the foreground?

    Windows 7 environment.