18

I have scheduled a task to be run at system startup. But its not working. When I run the task manually, it is working. Below are the screenshots of the settings.

enter image description here

enter image description here

What have I done wrong here? This task executes a bat file that launches a process. Btw, the result of last execution is shown as successful though.

AnOldSoul
  • 389
  • 1
  • 3
  • 8
  • What is "Kube Watchdog"? Google only finds Kube Studios on BBC Watchdog. What kind of process is it and what it is supposed to do when you launch it at system startup? – Esa Jokinen May 09 '17 at 07:36
  • It is a process that monitors some of the windows services we have developed. When I run it manually from task scheduler it works fine. Just that system startup is not happening – AnOldSoul May 09 '17 at 07:53
  • Try removing the checkmark from "Do not store password" – Mikael Dyreborg Hansen May 09 '17 at 09:04
  • It's 2 years later and I haven't been able to find a solution for this. 'Run whether use is logged on or not' apparently doesn't work? – Daniel Scott Jan 21 '19 at 22:38

8 Answers8

8

I struggled a while with the same problem. In my case, the problem was the setting "Start the task only if the computer is on AC power".

4

You are executing this Task with "VM" user privileges. Does "VM" account have "Run as a batch Job" rights?

How are you setting up your scheduled task, through local Task Scheduler or through DC GPO Preferences. What I've noticed is if the task is created through DC GPO Preferences is the same ... task will never execute (no matter what you are executing, VBS, PowerShell, CMD, EXE) if the only trigger is "At startup". I must create my Tasks with two triggers:

  1. At task creation/modification

  2. At startup

Now the task executes correctly every time I restart my computers.

REMARK

  1. This only applies if the Tasks are created through GPO Preferences on the DC side.

  2. This only applies for the trigger "At startup". As far as I have seen, every other trigger works fine.

  3. Be sure not to use "Replace" mode when creating this GPO Preference if you do not want for the Task to execute every time computer refreshes it's GPO's. In "Replace" mode during refresh the Task is being recreated and the trigger is "At task creation/modification". Use "Update" mode instead. Also this is where you see one problem with this workaround ... you can not create the Task in this way that should delete itself once the Computer is no longer part of Domain because those kind of Tasks require the "Replace" mode.

toofat
  • 271
  • 1
  • 11
2

Why don't you run this batch file as a windows service? Is there any particular reason? FYI: http://nssm.cc/usage

Yasitha Bogamuwa
  • 403
  • 1
  • 3
  • 12
  • Yes that's a valid question. This process is supposed to launch an application for which the UI should be visible. That's why this has to run as an independent process and not a service – AnOldSoul May 09 '17 at 09:44
  • So how can it run a GUI when the computer has only just started and nobody is logged in? Are you sure you don't want to run at user logon instead? – Dan May 09 '17 at 10:17
  • But still, why is this not working? What I've done – AnOldSoul May 09 '17 at 10:33
2

Your program isn't a background script or a service. It is a GUI program that should be run as a user in graphical environment. Therefore you should not launch it as a scheduled task on startup but on user login.

As the program is in your own development, you could revise its design: should it have a background service doing the background operations and separated GUI for configuration / monitoring?

Esa Jokinen
  • 43,252
  • 2
  • 75
  • 122
  • I can have it on user login as well. But that would mean that I need to have the login credentials of every machine that this is installed. It would be rather nice to have it on startup is what I thought. Besides these, why wouldn't this created task work? I tried simply writing to the file on startup, that too doesn't work – AnOldSoul May 15 '17 at 02:32
2

I also have problems with Win 10 task scheduler, and for some reason I have same behaviour as you. Task is marked as successfully executed but the program/script does not run.

In order to solve this, at least it works for me, try placing a shortcut of the script as a startup program in %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup.

You can also make this shortcut be runned with highest privileges (Admin). I've found this to work better than task scheduler, at least for my software/scripts. Some of them run with GUI and some without GUI, but both of them run fine under Startup folder.

PD: %APPDATA% is an system variable, the full path should look like the following:

C:\Users\YourUserName\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Alpha2k
  • 121
  • 1
  • 5
2

Is fast boot enabled in the BIOS? Win10 uses restart in a similar fashion to sleep mode if fast boot is enabled, so is not a true 'restart'.

guest
  • 21
  • 1
0

Put the script in the startup folder for all users %allusersprofile%\Microsoft\Windows\Start Menu\Programs\Startup you can even make it run as admin if needed be editing the properties of the shortcut

0

I just had this issue while setting up UI tests on Jenkins slave machine, but with one difference - I'm using the "Run only when user is logged on", so not sure if it makes a difference. I fixed the issue with following steps:

  1. Press Win + R
  2. Type secpol.msc and press Enter - The Local Security Policy manager opens
  3. Go to Security Settings – Local Policies – User Rights Assignment node
  4. Double click Log on as a batch job on the right side
  5. Click Add User or Group…
  6. Select the user and click OK

Taken from this article.