Back to writing

[windows]

Run as Administrator on login

I have a few long-running / daemon programs that I would like to "run as administrator" automatically when I start my computer, without UAC prompts. The programs are not available as Windows Services.

First, I tried placing an lnk shortcut in the Startup folder [1] with the "Run this program as an administrator" box checked. However, this didn't work, and I found that the program simply didn't start at all.

My next attempt was to use the Task Scheduler:

This worked, but the problem was that the task would be permanently stuck in the "task is currently running (0x41301)" state. So, I instead told the task scheduler to start cmd.exe with a command that immediately launches the real target program:

This solved the state problem because the cmd.exe finishes immediately, and that's all the task cares about.

The final problem was that the program would become slower and slower and slower over time. After a day of computer uptime, the program would be unusably slow. I found the solution to this problem here, which explains that scheduled tasks are started with below normal process priority. The fix (copied here for preservation) was:

  1. Export the task to an xml file.
  2. In that xml file, replace <Priority>7</Priority> with <Priority>4</Priority> and save it.
  3. Delete the task from the Task Scheduler UI.
  4. Re-import the task from the xml file.

[1] %appdata%\Microsoft\Windows\Start Menu\Programs\Startup


View this document's history

Contact me: writing@voussoir.net

If you would like to subscribe for more, add this to your RSS reader: https://voussoir.net/writing/writing.atom