I have a Java program and I need to create a Windows Service from within that Java program. I want to basically run the command line
sc create \"" + serviceName + "\" binPath= \"" + batFile + "\" start= auto
However, when I run this process from within Java I get an error
[SC] OpenSCManager FAILED 5:
Access is denied.
This command works fine if the user is an administrator, however my users of this Java program will not be administrators. How do I create a Windows Service from within Java (or by running external programs) without the user having administrator privileges?
Edit: Apparently this isn’t possible. Is there another way in Windows to execute a program at machine start up other than through a Windows Service?
It is not possible to create service in windows without Administrator privileges.