Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We want to autorun d:\func.bat when we log in to Windows 8.

We have added test.cmd to C:\Users\<User Profile>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup. When we reboot or start Windows 8 and auto run d:\func.bat, but we found some tools as administrator.

I want to auto run Command Prompt as Administrator and run d:\func.bat result ok.

share|improve this question

Try using Task Scheduler to run the desired batch or cmd file at startup.

The difference with Task Scheduler is that you can provide credentials with which the application should run(Administrator in your case).

share|improve this answer
I will verify this way,thanks! – Sam Jun 13 '12 at 2:10
i have tried out this way, but it cannot work.could you support to detail information?thanks – Sam Jun 14 '12 at 3:46
Don't forget that you have to start the batch file via cmd.exe /c test.cmd – Robert Nov 29 '12 at 13:32

Regarding CMD Run as Administrator

What I do is right click the program or its shortcut: Properties, seek an Advanced button, tick - Run as Administrator.

Click OK, then OK the next menu.

share|improve this answer
I want to let the machine auto run this batch file when login Windows 8 OS – Sam Jun 20 '12 at 2:13
Hello me. Anyway, You could turn of UAC, but that might not be very safe. I think Task Scheduler would be the best way as tumchaaditya said. – Sam Dec 31 '12 at 4:30

Put this at the top of your bat file. Thanks to who ever figured this out. not my code. Tested on Windows 10 x64

@echo off
:: BatchGotAdmin (Run as Admin code starts)
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
exit /B
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
:: BatchGotAdmin (Run as Admin code ends)
:: Your codes should start from the following line
share|improve this answer
Do you not have a source at all? – Burgi Apr 29 at 16:40

You must log in to answer this question.

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