43

I'm currently running a startup script in form of a bat file successfully in Windows 7 (I've inserted a new registry key entry with the bat file path as value in

Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run).

Now I need to run another bat file at startup, but with elevated rights (as administrator), and without manually confirming a prompt.

How can I achieve this, preferrably without external programs?

joe
  • 12,431
simon
  • 1,663

8 Answers8

28

See this article : Run UAC restricted programs without the UAC prompt.

This article shows how to use the Task Scheduler to launch startup programs with elevated privileges. Some small changes may be required in your case, but the article is well-written with screenshots.

The answer Schedule a task with admin privileges without a user prompt in windows 7 is useful in this case; in particular "Run with highest privileges" is really important.

harrymc
  • 498,455
4

Make two batch files:

StartAs.bat contains something along the lines of:

runas /user:SomeLocalAdminAccount c:\Users\MyUser\StartupWhat.bat

StartWhat.bat contains the commands that you want to run.

Gareth
  • 19,080
vana.yp
  • 49
3

Have you thought of a different approach? Either a pure group policy for the equivelent registry setting, else setting the batch file to run as a group policy. It maybe that you could even run it as a computer script, rather than a user script.

Start with gpedit.msc. However, it does need Ultimate or one of the other top end editions.

Guy Thomas
  • 3,348
3

hstart.exe - 3rd party start.exe replacement at http://www.ntwind.com/software/hstart.html

The invocation is a bit of a pain, but it works really well.

ClioCJS
  • 346
2

AutoExnt utility, from the Resource Kit.

The AutoExNT service permits an administrator to configure a Windows based computer to run a custom batch file when first starting the computer. Also, a user or administrator is not required to be logged on at the time this custom batch file runs.

joe
  • 12,431
1

runas /user:SomeLocalAdminAccount

Here must be like this:

runas /noprofile /user:mymachine\administrator cmd

runas /profile /env /user:mydomain\admin "mmc %windir%\system32\dsa.msc

runas /env /user:user@domain.microsoft.com "notepad \"my file.txt\""
studiohack
  • 13,477
1

Maybe UACPass (free) will solve it:

  • Install the program.
  • Open the UACPass window.
  • Drag to it the program you are pretending to run at boot.

Done. This program should now run as admin without UAC prompt.
The program even has an option for add to startup :-D .

Your program will only run after logon (or so I think).

-1

You can also make a shortcut and specify that the shortcut's file should be run elevated.

(It's in some advanced options box.)

riking
  • 11