jfromaniello / winser

Run a node.js application as a window service using nssm.
270 stars 47 forks source link

How install service with specific user (not local system account) #19

Closed sdnetwork closed 10 years ago

sdnetwork commented 10 years ago

it could be fine to specify the account that launch the service.

for exemple :

winser -i -s -c -u myaccount

what do you think about that ? maybe it's also possible but i don't see it.

jfromaniello commented 10 years ago

it seems nssm.exe (the thing that winser uses under the hood) has this options, so it should be doable:

http://nssm.cc/usage

DmitryVarennikov commented 10 years ago

Any progress on this issue so far?

DmitryVarennikov commented 10 years ago

I'm not a windows guy but from my understanding it may work the following way. As NSSM accepts a user account under which the service runs we can set it prior to installation: nssm.exe set ObjectName <username> then install & run

PSyton commented 10 years ago

Now you can do it with: winser --set="ObjectName " ...

wkentdag commented 7 years ago

@PSyton could you give an example of an actual command that you could use to set the user? Given a user will with a password myPassword, I tried:

winser -i -a -c --set="ObjectName will myPassword"

It failed with "Set operation failed (j)" . Here's the full output:

C:\Users\will\code\winsertest>winser -i -a -c --set="ObjectName will mytPassword"
continue installing "winsertest" as a service?  [y/n]: y
Use start command "node service.js".
The program "winsertest" was installed as a service.
  S S M :   T h e   n o n - s u c k i n g   s e r v i c e   m a n a g e r
 V e r s i o n   2 . 2 3   6 4 - b i t ,   2 0 1 4 - 0 6 - 2 9
 U s a g e :   n s s m   < o p t i o n >   [ < a r g s >   . . . ]

 T o   s h o w   s e r v i c e   i n s t a l l a t i o n   G U I :

                 n s s m   i n s t a l l   [ < s e r v i c e n a m e > ]

 T o   i n s t a l l   a   s e r v i c e   w i t h o u t   c o n f i r m a t i o n :

                 n s s m   i n s t a l l   < s e r v i c e n a m e >   < a p p >   [ < a r g s >   . . . ]

 T o   s h o w   s e r v i c e   e d i t i n g   G U I :

                 n s s m   e d i t   < s e r v i c e n a m e >

 T o   r e t r i e v e   o r   e d i t   s e r v i c e   p a r a m e t e r s   d i r e c t l y :

                 n s s m   g e t   < s e r v i c e n a m e >   < p a r a m e t e r >   [ < s u b p a r a m e t e r > ]

                 n s s m   s e t   < s e r v i c e n a m e >   < p a r a m e t e r >   [ < s u b p a r a m e t e r > ]   < v a l u e >

                 n s s m   r e s e t   < s e r v i c e n a m e >   < p a r a m e t e r >   [ < s u b p a r a m e t e r > ]

 T o   s h o w   s e r v i c e   r e m o v a l   G U I :

                 n s s m   r e m o v e   [ < s e r v i c e n a m e > ]

 T o   r e m o v e   a   s e r v i c e   w i t h o u t   c o n f i r m a t i o n :

                 n s s m   r e m o v e   < s e r v i c e n a m e >   c o n f i r m

 T o   m a n a g e   a   s e r v i c e :

                 n s s m   s t a r t   < s e r v i c e n a m e >

                 n s s m   s t o p   < s e r v i c e n a m e >

                 n s s m   r e s t a r t   < s e r v i c e n a m e >

                 n s s m   s t a t u s   < s e r v i c e n a m e >

                 n s s m   r o t a t e   < s e r v i c e n a m e >

Set operation failed (j)
palantus commented 3 years ago

Set operation failed (j)

I ran in to the same issue and fould a solution. Winser converts the "set" args to an array, but only if there are more than one of them. That is fine, but the problem is that it seems to require that it is always an array, making two or more --set necessary.

Try the following instead:

winser -i -a -c --set "ObjectName will myPassword" --set "Start SERVICE_AUTO_START"