Archive: ServiceLib.nsh - Can't create a network service


ServiceLib.nsh - Can't create a network service
I've searched through the forums and read the (very slow to respond) WIKI pages. I see that there are many topics regarding Windows services. Unfortunately none of them provide answers to the problems I am having.

servicelib.nsh doesn't seem to change the service from Local System account to a domain account when I specify a user and a password. The command executes cleanly and successfully, but when I open the Services applet and go to the Log On tab the service is set to "Local System account" and the account, password, and confirm password fields are blank.

Additionally, the display variable in the parameters doesn't seem to be respected. The display name of the service is the same as the service name.

The line I am using is:

!insertmacro SERVICE "create" "Backburner_Srv_200" "path=$ServerPath;interact=0;type=2;user=.\user;password=pass;display=Backburner Server"

Note: It seems there is a typo in the library's comments type=2 sets the service to auto start while type=3 sets it to manual start. This is the opposite of what is in the comments.

Any help with this would be greatly appreciated. Creating a network service with a proper user and password is the last hurdle I need to overcome to complete my project.


Re: ServiceLib.nsh - Can't create a network service

Originally posted by jeff_hanna
Note: It seems there is a typo in the library's comments type=2 sets the service to auto start while type=3 sets it to manual start. This is the opposite of what is in the comments.
Which ServiceLib.nsh is that? The one on the Wiki mentions nothing about a `type` argument. Is it newer than the Wiki version?

As for your questions, I have no idea.

Re: Re: ServiceLib.nsh - Can't create a network service

Originally posted by kichik
Which ServiceLib.nsh is that? The one on the Wiki mentions nothing about a `type` argument. Is it newer than the Wiki version?
Yes, it is. The library linked on the WIKI page is out of date. See this discussion for a link to dselkirk's latest release of the library.

That's weird... Both are labeled version 1.2 and the one on the Wiki has a newer date.


Shrug, yeah it is weird. I started with the one on the WIKI and then found that discussion. The linked file in that discussion has more features and was created as a revision to the first release. The author didn't update the version number or mod date in the file, though. It still shows v1.0

Anyway, I fixed the display name issue. It seems that the parameters must be seperated with a ; and also end with ;. I didn't have the trailing ; in my line.

Still can't get user/password info & network service stuff to work, though.


Hmmm... he doesn't answer in the forums since the end of 2003. Maybe contacting him by e-mail about problems?


I tried that a few days ago, dequix. There was no response. I guess at this time we should consider ServiceLib.nsh to be unsupported.

I found a workaround, though. So things are ok for me. From everything I found about the windows API call CreateService() and the ServiceLib.nsh file it appears as if the create method inside of ServiceLib.nsh is working as expected. Windows (XP) just doesn't seem to respect the user name and switch the service to a network service.

I found that if I use the DOS command SC immediately after creating the service I can use the config method within SC to set the user/password and WinXP will understand to switch the service to a network service. The command in my installer is:

nsExec::Exec "sc config backburner_srv_200 obj= .\<usr> password= <pwd>"

Where <usr> and <pwd> contain the actuall information for my network. If anyone else uses this and they are on a domain then .\<usr> should be changed to <domain>\<usr>

It's not as clean as having it all happen with ServiceLib.nsh, but it works and is transparent to the user.


Did you find a solution to your problem? I have changed the ServiceLib module to fix this (and other issues). If you still need this, I can give you a copy of my file.

Sven