Back to writing
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  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:
- Export the task to an xml file.
- In that xml file, replace
<Priority>4</Priority>and save it.
- Delete the task from the Task Scheduler UI.
- Re-import the task from the xml file.
View this document's history
Contact me: email@example.com