I would like to have the console window kept open when running a scheduled task which executes a batch file. If I run it manually - meaning execute the batch file - the window stays open. However, using task scheduler, the console window doesn't open even though I can see the task is running. I put a pause at the end to do this.
@echo off
TITLE PROCESS_MGR
tasklist /FI "IMAGENAME eq JOESMO.exe" | find /I "JOESMO.exe">nul &&(echo PROCESS
JOESMO.exe IS ALREADY RUNNING!
echo %DATE%
echo %TIME%
pause
) || (
echo JOESMO PROCESS IS NOT RUNNING
cmd /c start "JOESMO.exe" "C:\Users\xxxx\Documents\
Visual Studio 2010\Projects\Projects2013\JOESMO.exe"
pause)
I found this suggestion cmd /k myscript.bat
but having created the task in task scheduler for windows server 2008, I am not sure where to apply this. I added /k
to the add arguments box in edit action in the task.
In the Scheduled Task dialog, just before the name of the batch file it's going to run (it's labeled Program/script
. You now have something like:
myscript.bat
Change it to
cmd
Add the following to the **Add Arguments (optional) entry:
/k "C:\My Batch File Folder\MyScript.bat"
Tested on my system (Win7 64-bit), and it worked perfectly. I'm looking at the open command window it created as I type this text. :-)