I'm trying to set up a build process during which, a Windows service has to be started and stopped. I tried doing that by using the exec-maven-plugin
:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>startServer</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${project.basedir}/bin/startService.cmd</executable>
<workingDirectory>${project.basedir}/bin</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
The problem that I'm running into is, that to be able to control services, you need to have adminsitrative rights. My user is local admin so the script works if I run it in an elevated prompt (right click->'Run as Adminsitrator').
I've tried using runas /user:administrator
but it's prompting for a password. I could run the Maven build itself as admin but I'd like to run it from environments where this might not be possible (Eclipse, Jenkins).
Does anyone have an idea on how to implement the described scenario?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…