0

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!

user53864
  • 1,653
  • 8
  • 36
  • 66

2 Answers2

1

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
    )
)
fission
  • 3,506
  • 2
  • 20
  • 27
  • Logging-in to `Administrator` account, selecting `Run only when user is logged on` also with `run with high privileges` option and `Specifying the desktop user` under General tab, running the scripts on the desktop opening cmd at the scheduled time. As it's wroking I didn't try if it works with less options than what I'm using now. Thanks you! – user53864 Jul 25 '11 at 13:00
  • Any more tips/tricks with new task scheduler are welcome! – user53864 Jul 25 '11 at 13:02
1

In response to your comment above, there's 3 things you can do to verify your script was run correctly.

  1. You can check to make sure the scheduled task was successful.
  2. You can create a line at the end of your batch file to write a command to a file to show that it completed echo Script finished %date% %time% >> c:\batch\backupScript.log .
  3. You can run it manually.
Nixphoe
  • 4,524
  • 7
  • 32
  • 51