Skip to content
⌘ NSIS Forum Archive

NSIS Simple Service Plugin

142 posts

Speed78#
Re: One request

Hi,

Even a new function like SimpleSC::GetError would be helpful.
I think this function is helpful. I will add this in the next release.

Did you installed your service successfully now?

Best Regards

Rainer
Speed78#
New Version 1.20

Hi,

I´ve released a new version of the NSIS Simple Service Plugin. The changes are:

- Every function now returns <> 0 if there is an error. Use SimpleSC::GetErrorMessage to get the message of a function result
- Added function SimpleSC::GetErrorMessage to get the message of a function result
- SimpleSC::ExistsService results now 0 if the service exists and <> 0 if the service doensn´t exists
- SimpleSC::RestartService supports now arguments.

Note: The signature of the function SimpleSC::RestartService has been changed. If you update from a previous version you must check your parameters.

You can find more informations and download file on the wiki page (http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin).

If you have any questions please let me now.

Best regards

Rainer
Afrow UK#
I'm using the latest dll and SimpleSC::ExistsService is returning 0 when the service doesn't exist.

Stu
Afrow UK#
Also RemoveService appears to be returning a value other than 0 on success rather than on failure.

Edit: My bad on RemoveService. The other function still returns 1 when it exists though.

Stu
Speed78#
New Version 1.21

Hi,

I´ve released a new version of the NSIS Simple Service Plugin. The changes are:

- SimpleSC::ExistsService results now 0 if the service exists and <> 0 if the service doensn´t exists

You can find more informations and download file on the wiki page (http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin).

Thanks to Stu for reporting this bug. If you have any questions please let me now.

Best regards

Rainer
elllit#
Hi,

in my installer I want to stop and delete an already running service, install the data and then install and start it again.

Everything is fine, until it comes to the stopping/deleting point. It passes without error but the process stays active for another ~20s (on my system), causing the installer to show a message that the file, that is about to be installed, is currently in use.

The service actually does not exist anymore. So checking for existance does not work.

Sleeping for a static 30sec is not satisfying at all.

Using the nsProcess plug-in to see wether my service is still running or not might be a solution (will try it next). But I hope that there is a better out there.

Any suggestions?

-- Till
elllit#edited
Edit: Solved - Layer 8 issue *bangs the forehead on teh table*


---

Oh, there is another issue:

Installing for the standard user works flawlessly. But giving an account name and password it fails with error code 1057 that is: "Account invalid or does not exist" or something... I triple checked the strings and even hardcoded them into the script w/o success. :-(

Im trying to install on a 2003 Server if that might help.

Thanks,

-- Till
Speed78#
Hello Till,

Everything is fine, until it comes to the stopping/deleting point. It passes without error but the process stays active for another ~20s (on my system), causing the installer to show a message that the file, that is about to be installed, is currently in use.

The service actually does not exist anymore. So checking for existance does not work.
If the service doesn´t exists (Stopped & Uninstalled) the plugin has done his work. A question to figure out where the problem is:

Please try to stop your service with the plugin (not to uninstall!). After that please open your process list and check for your service process. Please repeat the same steps with the service manager. Does the service process exists in the process list?



Sleeping for a static 30sec is not satisfying at all.

Using the nsProcess plug-in to see wether my service is still running or not might be a solution (will try it next). But I hope that there is a better out there.
This is really nonsatisfying!

Best regards

Rainer
elllit#edited
Hi,

first: sorry for the delay in answering your reply.

Originally posted by Speed78
Hello Till,

If the service doesn´t exists (Stopped & Uninstalled) the plugin has done his work. A question to figure out where the problem is:

Please try to stop your service with the plugin (not to uninstall!). After that please open your process list and check for your service process. Please repeat the same steps with the service manager. Does the service process exists in the process list?
I actually did that, but somehow I did something that obviously has fixed the problem, because I never had that delay issue since then. 😕

Anyways... I now have a issue that seemed to work all the time but now giving me a hard time.

This is the code i use to start a service


${If} $S_StartNowInput == ${BST_CHECKED}
DetailPrint `Starting service`
LogEx::Write /NOUNLOAD `... starting`
LogEx::Write /NOUNLOAD `... >>> arguments: `
SimpleSC::StartService "${s_name}" ""
Pop $0
${If} $0 <> 0
#SimpleSC::GetErrorMessage
#Pop $0
LogEx::Write /NOUNLOAD `... [InstallService] ERROR: $0`
DetailPrint `Could not start service! - Reason: $0`
Goto cancel
${EndIf}

DetailPrint `... done`
${EndIf}
This fragment is, with some more pieces, enclosed in a macro. Before starting the service it is installed without any sign of error. When it comes to starting it runs into the 30sec timeout (i guess) and gives me "1053" as result. Which in words means: "The service did not respond to the start or control request in a timely fashion" or something similar.

I'm pretty confused because I couldn't track down the cause of this. I'm not that familiar with windows' service handling and thus not sure what to look for.

Any ideas? Thanks in advance.

Till
Afrow UK#
This to me would suggest a problem with the service itself. I personally have had no problems with SimpleSC installing, starting, stopping or uninstalling services.

I have seen that kind of error in a service that does not start the main thread in its start method.

Stu
Speed78#
Hello Till,

please try this script:

----------------------
Name "test"
OutFile "test.exe"

!Define SERVICE "TapiSrv"

Section
MessageBox MB_OK "NOTE: Result '0' means it was success otherwise '1'"

MessageBox MB_OK "Starting Service: ${SERVICE}"
SimpleSC::StartService "${SERVICE}" ""
Pop $0
MessageBox MB_OK "Result: $0"

SectionEnd
----------------------

This script will start the tapi service (In german: "Telefonie"... I don´t know the name in english 🙁 )

I tested this script without any problems. If you also have no problems with this script I think the problem is your service. Can you check this and please give me a feedback!?

Best regards

Rainer
elllit#
Speed78,

thanks for helping me.

The result your skript gives me is "1056".

The service "Telefonie" is running on my system and I can't stop it apperently (Error "1053" again). When I try to stop it via the services control list it says it needs to stop "RAS-Verbindungsverwaltung" which has "Telefonie" as a dependency. This is where the error comes into place. I guess it is used in the background somehow(?).

I'll talk with guys who code the service to check if the problem is on that side, following Afrow UK's suggestion which I also considered as another spot to search for a solution. But trying to find the error on oneself is the first way to go, isn't it? 😉

Till
elllit#
Update:

I manged to get one service running with the help of a developer. The problem was that a dependency wasn given for the service, which I didn't know about.

Anyways, installing the other service mine is depending on solved the problem.

I hope its as "easy" with the other service. I will ask the colleague on monday and report about it.

I apology for bothering you as it was a fault on my side 😉
elunkes#
How can i get the LOGON NAME in a service

we have

SimpleSC::SetServiceLogon [name_of_service] [account] [password]

but i want something like this

GetServiceLogon (or something)

can ai get it ?
Speed78#
Hi,

the next day I will released a new version of the plugin. I will implement this function in the new version.

Best regards

Rainer
Speed78#
New Version 1.22

Hi,

I´ve released a new version of the NSIS Simple Service Plugin. The changes are:


- SimpleSC::GrantServiceLogonPrivilege and SimpleSC::RemoveServiceLogonPrivilege works now correct with domain names like MyDomain\MyUser.

- Added function SimpleSC::GetServiceLogon to get the logon username of a service.


You can find more informations and download file on the wiki page (http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin).

Thanks to everyone for reporting bugs and requesting features. If you have any questions please let me now.

Best regards

Rainer
elunkes#
Hi Speed78,

this version of SimpleSC was detected as a TROJAN when i used it in my compilation script

With version 1.21 there is no problem (but also there is no new functions)

without a antivirus , the new functions works right.

i'm using "Avast" in my computer.

could you review this version 1.22?

thank you
Speed78#
Hi,

I´ve checked the file and here the results.




I´ve contacted AntiVir and Webwasher. AntiVir gave me the answer that the file is a FALSE-POSITIVE File and that they will modify the virus definitions. Webwasher gave me no answer at the moment.

I´m really confused about this because I only change some lines in the code and the scanner found a "pseudo"-virus.

I couldn´t determine some problems with "Avast". So you can take a look to the VirusTotal-URL.

Best regards

Rainer
Speed78#
New Version 1.23

Hi,

I´ve released a new version of the NSIS Simple Service Plugin. I detected that the compiler optimazation results in a false-positive virusscan, so I´ve removed it a I hope the problem is solved now.

You can find more informations and download file on the wiki page (http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin).

Thanks to everyone for reporting bugs and requesting features. If you have any questions please let me now.

Best regards

Rainer
phunkydizco#
I have a service that takes some time to stop. How can I stop the service and wait until it is really stopped?
Speed78#edited
Hello,

take a look at the documentation: http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin

The "SimpleSC::StopService"-Function is what you are searching for.

Kind regards

Rainer
Speed78#
New Version 1.24

Hi,

I´ve released a new version of the NSIS Simple Service Plugin. The changes are:


- Fixed wait for status bug if the service status changed. Now, if a service stops, starts aso. the plugin will work like the recommendations in the MSDN. On some systems (especially 64Bit systems) the plugin returns "Stopped" although the service was not really stopped.

It is recommend to update your version of this plugin. You can find more informations and download file on the wiki page (http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin).

If you have any questions please let me now.

Best regards

Rainer
amclellan#
Setting only the binary path

I've been using version 1.24 of SimpleSC and I really appreciate it's ease of use. I'm currently working on a issue where the a service has been previously installed and now I'm trying to update only the binary path if it happened to be installed in a different location without changing the other settings associated with the service. Is there a SetServiceBinaryPath or some other way of performing this action.

Thanks

Allan McLellan
Speed78#
Hello Allan,

unfortunately, there is no possiblity to change the binary path. At the moment I recommend the following procedure:

1. Deinstall the service old "RemoveService"
2. Install the new service with the new binary path "InstallService".

Nethertheless, I will add the method "SetServiceBinaryPath" in the next version of this plugin, but this will take some weeks.

Kind regards

Rainer
amclellan#
Hi

Thanks for getting back to me so quickly. I'm currently checking to see if the new binary path equals the old binary path and if they don't then pop up a message box requiring the user to manually go in and change it via the service manager. It's not the nicest, but it doesn't really happen all that often. Again thanks for the quick response.

Allan
Speed78#
Hello Allan,

I think to compare the binary path of the old service with the new service is a good idea. But if the paths are not equal I think it´s more comfortable just to remove the old service (Take a look at SimpleSC::RemoveService) and install it again (Take a look at SimpleSC::InstallService). I think this should work. At the moment there is not possiblity to change the binary path in the service manager directly (AFAIK until Windows 2003). So the only way to change it is via command line "sc.exe".

Kind regards

Rainer
saill#
Originally posted by elllit


Installing for the standard user works flawlessly. But giving an account name and password it fails with error code 1057 that is: "Account invalid or does not exist" or something... I triple checked the strings and even hardcoded them into the script w/o success. :-(

Im trying to install on a 2003 Server if that might help.

Thanks,

-- Till
Hi Till,

We ran into the same problem. Turns out Windows wants the account name to be preceded by ".\". We figured this out by having Windows report the account owning the service. This works on XP, we're hopeful it will hold for other Windows platforms.

Just to be safe, we started the service as admin, then set service logon to the desired account.

The code that worked looks like this:

SimpleSC::InstallService "MyService" "My Service Display Name" "272" "2" "C:\MyPath\MyService.exe" "" "" ""

SimpleSC::SetServiceLogon "MyService" ".\MyServiceUser" "MyServiceUserPassword"
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
IntCmp $0 0 +1 Done Done ; If successful grant the service logon privilege to "MyServiceUser"
; Note: Every serviceuser must have the ServiceLogonPrivilege to start the service
SimpleSC::GrantServiceLogonPrivilege ".\MyServiceUser"
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
Done:


Rainer, thanks for the great tool. Really saved our butts with this particular bug!

Saill
Speed78#
Hi Saill,

if I understand you correctly your problem with SetServiceLogon is ".\"-prefix of a non domain-account? I will check this for the next plugin-version.

Kind regards,

Rainer