3

I'm currently using CruiseControl.NET to automate my build. We have two different ways to build a solution in my build environment - one is through the Keil uVision4 IDE, the other is through Visual Studio 2008.

I've successfully gotten the Visual Studio solution to build properly using CruiseControl.NET and have created a batch file which properly uses Keil's uVision command line interface to compile my uvproj Project (compilation details here).

Problem Description

1) I can successfully execute the build script on my Windows 2008 server and build the project if I create a command prompt with administrator privileges (I'm doing this manually - start -> run -> cmd with ctrl-shift-enter to run as admin).

2) However, if I create a command prompt without administrator privileges, and attempt to execute the batch file, the batch file won't work unless I accept the prompt asking me to confirm admin rights are required to run the batch script.

How do I automatically execute a batch file as an administrator through CruiseControl?

Is this something that could be automated using the RunAs command?


Technical details

1) The batch file being executed is pretty simple - it deletes the old output and re-makes the output, creating a build log file in the location below.

set BuildLogLocation=BuildLog\BuildLog.txt

echo on
cd ../..
cd PTM
rmdir /s /q output
mkdir output
mkdir BuildLog
C:\Keil\UV4\UV4.exe -r myProj.uvproj -o %BuildLogLocation%

echo ErrorLevel of build is %ERRORLEVEL%
echo build complete, see %BuildLogLocation%

2) Currently I'm looking to use the Exec functionality to run the Keil build script above:

<Exec>
    <Command>C:\myProject\Build\KeilBuild\BuildScript.bat<Command/>
    <buildTimeoutSeconds>600<buildTimeoutSeconds/>
    <!-- Details about error codes can be found here:
    http://www.keil.com/support/man/docs/uv4/uv4_commandline.htm -->
    <successExitCodes>0,1</successExitCodes>
<Exec/>

Related questions:

Community
  • 1
  • 1
CrimsonX
  • 9,048
  • 9
  • 41
  • 52

4 Answers4

1

Can you run CCService, the CruiseControl.NET Windows Service, as a user who has administrative permissions? I'd try that first.

If that doesn't work, I would use runas to run your script. You'll have to embed the administrative user's password in the script calling runas.

Aaron Jensen
  • 25,861
  • 15
  • 82
  • 91
1

I know this is old but, Did you get an offical way to do it Via Cruise Control?

Normally I create this and call it to call other processes "As Admin".

Make a ".VBS" script with This in the contents:

Dim strBatchPath

strBatchPath = "PATH-TO-FILE.EXE"

Set runBatch = CreateObject("shell.application")

runBatch.shellexecute strBatchPath,,,"runas",1

That could be an option to people that can't find an official way

Adam Lacey
  • 103
  • 1
  • 11
0

You could try psExec from sysinternals. If you don't need to run as a nt-authority account you should be able to use this in the same way as runas. It allows you to pass in the username/password as a switch (if memory serves)

Simon Laing
  • 1,194
  • 7
  • 18
0

I have Discovered that when using PSEXEC and using the -h switch, it then "runs as admin" on destination

e.g.

psexec -h \ServerToRunOn /accepteula -u DOMAIN\USER -p PASSWORD "PATH-TO-FILE"

I am Using CC.Net to call a batch file with the above in. This will run that file as Admin

Adam Lacey
  • 103
  • 1
  • 11