How to schedule batch file to run on the desktop in win 2008 R2

batch-filebatch-processingtask-managerwindows-server-2008-r2

I have some backup batch file scripts which I was running in xp and I have migrated to windoes server 2008 R2 where it's not running in front when scheduled with task manager. I struggled a lot to make it run at the scheduled time with task manager and it's running but not showing the process(running in the background). I also know the option to display all the running tasks. I searched in the google and I didn't find it so far. Does anyone know how to make task manager execute .bat file on the desktop(opening cmd prompt) in windows server 2008 R2?. I scheduled it to run as same desktop user!.

Thank you!

Best Answer

Tasks can only launch interactively when you use the Run only when user is logged on option. Here's an excerpt from the Task Scheduler help file:

You can specify that a task should run even if the account under which the task is scheduled to run is not logged on when the task is triggered. To do this, select the radio button labeled Run whether user is logged on or not. If this radio button is selected, tasks will not run interactively. To make a task run interactively, select the Run only when user is logged on radio button.

I experimented a bit with psexec -i but no luck, sorry.

You can find a list of running scheduled tasks with schtasks.exe, eg:

schtasks /query | find "Running"

If you want to get a bit fancy, you could pull out the command line for each running task as well. Here's a batch file example:

@echo off
for /f "delims=," %%i in ('schtasks /query /fo csv ^| find "Running"') do (
    for /f "delims=, tokens=9" %%j in ('schtasks /query /fo csv /v /tn %%i ^| find /v "Next Run Time"') do (
        echo %%~i   %%j
    )
)