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 c开发者_开发问答reate 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.
It isn't possible to create a windows service without Administrator privileges. Similarly, you won't be able to launch any executables through the System Configuration Utility's startup tab (msconfig). If you're unable to obtain Administrator privileges, would it be enough to create a shortcut in your account's startup folder?
If this is something you need just for you then that should do the trick. If this is something you'll need for multiple user accounts you'll need to be an Administrator.
You cannot. Adding a service requires administrator privileges.
精彩评论