20

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.

4
  • 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? May 9, 2017 at 7: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 9, 2017 at 7:53
  • Try removing the checkmark from "Do not store password" May 9, 2017 at 9:04
  • 1
    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? Jan 21, 2019 at 22:38

9 Answers 9

10

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".

5

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.

1
  • I found another way to work around Task Scheduler tasks created via GPO using the 'At startup' trigger failing was enabling 'Apply once and do not reapply' under the Common tab - this means you can use Replace. instead of Update.
    – Minkus
    Jun 8 at 11:00
2

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

3
  • 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 9, 2017 at 9: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 9, 2017 at 10:17
  • 1
    But still, why is this not working? What I've done
    – AnOldSoul
    May 9, 2017 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?

1
  • 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, 2017 at 2: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
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'.

1

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.

1

I know this is an old post but setting up a small MeLE mini-computer with Windows 11 and tried to start mobile hotspot from a powershell script at system startup, I fumble upon the same problem!!!! And what was even more frustrating was the fact that on a reboot the script will run but not on a cold start. So my workaround was to look for "other events" that occur at bootup and I found those in the System Windows Logs: enter image description here

So all I did is add a trigger on an event and watch for this 566 event: enter image description here

And voilà! Now my Hotstop start on cold start everytime! Hope this help.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .