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.

3 Answers 3


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

  • i have tried out this way, but it cannot work.could you support to detail information?thanks
    – Sam
    Jun 14, 2012 at 3:46
  • 1
    Don't forget that you have to start the batch file via cmd.exe /c test.cmd
    – Robert
    Nov 29, 2012 at 13:32

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

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.

  • 2
    I want to let the machine auto run this batch file when login Windows 8 OS
    – Sam
    Jun 20, 2012 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, 2012 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.