1

I am using Albacore and I want to run a batch file that needs to be elevated as Administrator. The rights are checked as:

Batch file:

AT > NUL
IF %ERRORLEVEL% NEQ 0 GOTO AdminRightError

:: more code here

:AdminRightError
ECHO You are not running as administrator!

Rakefile:

exec :CmdRunBatch do |cmd|
  cmd.command = "RunCommands.bat"
end

When I execute rake CmdRunBatch through a normal (non-elevated) command-line I get the AdminRightError described in the batch file. Is there a way to solve this issue?

Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188
ColdFusion
  • 93
  • 8
  • I'm not following, I expect the rake task to fail in a normal prompt... are you asking how to elevate a command? I changed the question title to reflect that, hope I'm right :) – Anthony Mastrean Sep 19 '13 at 17:47
  • I'm curious, if you try to run as admin, a UAC dialog will appear. You'll have to dismiss it. Unless you have UAC off, in which case, you're already admin. Is this running on a build-server or manually on your local machine? – Anthony Mastrean Sep 19 '13 at 17:57
  • 1
    I refer you to another answer I just provided: http://stackoverflow.com/a/18902122/3619 – Anthony Mastrean Sep 19 '13 at 18:17
  • Anthony, thanks for the comments! I do this: Run visual studio 2012 with the 'Rake Runner' extension. My script needs elevation but because VS is not elevated, the script fails. Is there a way to ask for UAC elevation when I run the script? -Edit: I think your answer is giving some insight, I will check! – ColdFusion Sep 23 '13 at 09:21

0 Answers0