1

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

1 Answer 1

2

You need to add doman before username:

%PRUNSRV% //US//%SERVICENAME% --ServiceUser <domain>\<my_user> --ServicePassword <password>

If You want to set local user as ServiceUser You could try like this

%PRUNSRV% //US//%SERVICENAME% --ServiceUser .\<my_user> --ServicePassword <password>

That worked for me. I found this in Procrun documentation

Specifies the name of the account under which the service should run. Use an account name in the form DomainName\UserName. The service process will be logged on as this user. if the account belongs to the built-in domain, you can specify .\UserName

Kind regards

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.