Hi,
I am having issue with creating task to run a window system command to stop a window service.
task startMyService(type: Exec) {
executable = ‘sc’
args = [‘stop’, ‘myServiceName’]
doLast {
println ‘startMyservice done’
}
}
Here are my steps
- open a Window Command Prompt as Administrator
- execute the following command to make sure I have the permission. myService is started
sc start myService - after manually stop myService, execute the following command and I got error
gradlew startMyService
Task :startMyService FAILED
[SC] StartService: OpenService FAILED 5:
Access is denied.
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ‘:startMyService’.
Process ‘command ‘sc’’ finished with non-zero exit value 5
It seems to me is the Gradle task doesn’t have the permission to run a window system command. Does anyone run into such issue and any solution/suggestions?
Thanks,
Simon