I'm using prunsrv to run a jar file as a windows service.
I need to change the user that runs the service from LocalSystem to a machine user and i can't seem to make it work.
This is the bash script i have to create the service:
%PRUNSRV% //IS//%SERVICENAME% --Startup auto --StartClass <start_class_name> --StopClass <stop_class_name>
%PRUNSRV% //US//%SERVICENAME% --DisplayName "%DISPLAYNAME%" --Description "%DESCRIPTION%"
%PRUNSRV% //US//%SERVICENAME% --StartMode jvm --StopMode jvm --Jvm %JVM_DLL%
%PRUNSRV% //US//%SERVICENAME% --StartMethod start --StopMethod stop
%PRUNSRV% //US//%SERVICENAME% --Classpath "%APP_CLASSPATH%" --JvmMs 128 --JvmMx 256
%PRUNSRV% //US//%SERVICENAME% --JvmOptions %JAVA_OPTS% %LOG_OPTS%
As per the documentation, i've tried to run the command
%PRUNSRV% //US//%SERVICENAME% --User <my_user> --Password <password>
and
%PRUNSRV% //US//%SERVICENAME% --ServiceUser <my_user> --ServicePassword <password>
but with no effect.
If i put a user with the wrong password, i get a message saying
The account name is invalid or does not exist, or the password is invalid for the account name specified.
but i don't have any feedback when the user and password are correct, and when i open the Windows Services, i can see my service installed and running, but always as LocalSystem.
I've noticed that when i change the user in the service properties, it changes a property called ObjectName in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<ServiceName>
and when i run the prunsrv with --User and --Password it adds a property called user in
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\ProcRun 2.0\<ServiceName>
Can someone give me a hint on how i can change the user with prunsrv?
Thanks
You need to add doman before username:
If You want to set local user as ServiceUser You could try like this
That worked for me. I found this in Procrun documentation
Kind regards