1

I have a Task created on Windows 2012 Server, that is set to run when I login, and it does just that, when I login it starts running, and if I want to I can run it manually:

https://i.stack.imgur.com/5s5Jk.jpg

I created another task, with the same exactly settings, but set to run whether I'm logged or not.

https://i.stack.imgur.com/zCuOP.jpg

This task does not tun automatically (although the log says it does), and I can't even run it manually, when I try to run it manually nothing happens.

What can I change to make it run?

  • The log says it runs, what makes you think it doesn't? You may need to improve your BAT script logging to see what's going on. – mfinni Jun 09 '22 at 15:30
  • @mfinni when the script runs it opens a cmd window, and it runs some commands, so it's possible to visualize if it's working or not, that´s how I know TASK 2 does nothing – questionador Jun 09 '22 at 15:35

1 Answers1

2

https://social.technet.microsoft.com/Forums/ie/en-US/c03d6691-b058-4f8d-961c-e8eba25bbaed/task-scheduler-problem-run-whether-user-is-logged-on-or-not?forum=w7itprogeneral

The answer says

There is some pertinent info for your issue in the Task Security Context topic in the Scheduler help file...

Specifically, it says, "...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

So if you're expecting to see a window, you will not. As I said, add some logging if you need to troubleshoot further.

mfinni
  • 36,144
  • 4
  • 53
  • 86
  • the only difference between the two tasks is precisely that, one is set to run at my login and the other should run either way. If I change this they will be equal. Thing is when I set it to run whether I'm logged in or not it stops working – questionador Jun 09 '22 at 16:39
  • 1
    you've missed the point. When a task is non interactive, it will NOT make a window. "run when not logged in" means non interactive, which means no window. – mfinni Jun 09 '22 at 17:13
  • I believe in what you said. But the thing is, that bat, runs a command that fetches a file from an online platform. The task set to run when I log in works, and the other one does nothing at all... – questionador Jun 13 '22 at 12:49
  • So add some logging to the script, like I suggested. Find out where it's failing. Post the BAT file here. – mfinni Jun 13 '22 at 15:54
  • Here is the logging: https://imgur.com/a/ug6khRm It can't be the bat, because it works when logged, so it had to work on this task too! – questionador Jun 14 '22 at 16:00
  • You are still missing the point entirely. Add logging into your BAT file itself and figure out what isn't working. – mfinni Jun 14 '22 at 22:43
  • I'm sorry, language barrier, I completely misunderstood what you said. Going to try it – questionador Jun 15 '22 at 10:34
  • Just tell me something, if I start the BAT file with @echo off set "username=1234" set "password=test" will do the trick? – questionador Jun 15 '22 at 10:39
  • what trick? Those aren't writing anything to a log file – mfinni Jun 15 '22 at 17:05
  • I'm sorry mate, I really don't understant what you are suggesting me to do! – questionador Jul 06 '22 at 09:47
  • Stop trying to interact with the console (because it DOESN'T EXIST when running non-interactive) and try writing to a file. That will show you that your task is or isn't running, – mfinni Jul 06 '22 at 21:03
  • I'm trying to make you proud :) created another batch file with the code "rem Saved in C:\WriteText.bat @echo off echo This is a test> test.txt echo THIS IS IT>> test.txt echo OR IS IT>> test.txt" and a similar task to run it. nothing happens, nothing at all... – questionador Jul 12 '22 at 08:32
  • Are you sure it's doing nothing? You're a sysadmin, start troubleshooting. What's the "Start in" directory for your task's action? If you haven't set one, it's probably putting the output in your system directory. Either specify the starting directory, or declare a full path to your logfile. Use a tool like procmon to monitor what your BAT is doing at this point. – mfinni Jul 12 '22 at 15:40