Skip to content
⌘ NSIS Forum Archive

NSIS Simple Service Plugin

142 posts

saill#
Hi Rainer,

Exactly. My experiments show that any for any [account] input you need to add the ".\" prefix. Once you do that, it works great.

No real need to fix it - a note in the documentation should do the trick.

Thanks a lot for the tool. We used it to make sure that our service was owned by the current user so we could kill our runtime cleanly at shutdown. Solved one of our trickiest Windows bugs!

Warm regards,

Saill
Speed78#
Hello Saill,

I changed it in the online documentation but addionally I will change this in the next version.

Kind regards

Rainer
saill#
Hi Rainer,

That's great! I believe the .\ prefix is also necessary in the "account" input for:

SimpleSC::InstallSevice
SimpleSC::GrantServiceLogonPrivilege
SimpleSC::RemoveServiceLogonPrivilege

Warm regards,

Saill
Sadeesh#
1053 Error while starting the service

Hi,

I am trying to install a bat file as service.
I am able to create the service, but i am not able to start the service via script.
When i try to start the service manually i get the following windows error message.

"1053 service did not respond to the start or control request in a timely fashion"

Can anyone help me to fix this?

Thanks in advance,
Sadeesh
kichik#
You can't use a batch file as a service. Not every program can be used as a service. It must be specifically designed for this purpose. There are some helpers that can turn any application to a service. Google "turn any application to a service" or something similar and you should be able to find them.
pineapplex#edited
Batch file as service

I found a solution in order to use a Batch file as service. I used Flash Mx to create an EXE file that contains a FSCommand opening the Batch file. At last, the batch file is working as service.

I hope it works for you.

But I have another question:

I have a service running (not a batch file, of course). What's the best way to "interact" with the service? I have the service running but I can't find the way to open my application and change some config parameters, for example.

Can you help me with this issue?

I'm sorry for my english. I hope you can understand me.

Best wishes from Spain.
aerDNA#
v1.24 - WZCSVC problem

Version 1.24 has a problem (at least on my system) with stopping the Wireless Zero Configuration.
SimpleSC::StopService "WZCSVC" does stop the service but is unaware of the status change and returns an error after the 30 s timeout ("The service did not respond to the start or control request in a timely fashion").
I tried several other windows services and there was no such problem. Version 1.23 deals with WZCSVC successfully. My system is XP SP2 but Wireless Zero Configuration has been updated (hotfix KB917021).
Speed78#
New Version 1.25

Hi,

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

- SimpleSC::SetServiceLogon supports now non-domain username without the ".\"-prefix
- SimpleSC::SetServiceBinaryPath function added

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.

Kind regards

Rainer
Speed78#
Re: v1.24 - WZCSVC problem

Hello,

Originally posted by aerDNA
Version 1.24 has a problem (at least on my system) with stopping the Wireless Zero Configuration.
SimpleSC::StopService "WZCSVC" does stop the service but is unaware of the status change and returns an error after the 30 s timeout ("The service did not respond to the start or control request in a timely fashion").
I tried several other windows services and there was no such problem. Version 1.23 deals with WZCSVC successfully. My system is XP SP2 but Wireless Zero Configuration has been updated (hotfix KB917021).
sry... I read this just now after releasing 1.25. I will check this on XP SP2 the next days. If you stop your service manually (via service control center) how much time takes it to stop the service (> 30 seconds) ?

Kind regards

Rainer
aerDNA#
Re: Re: v1.24 - WZCSVC problem

Originally posted by Speed78
If you stop your service manually (via service control center) how much time takes it to stop the service (> 30 seconds) ?
When stopped manually, everything's ok (takes about 2 sec). With SimpleSC 1.23 it's also fine. The problem is with v1.24-1.25. Starting the service works ok in new versions, although it takes several seconds longer than with 1.23.
pineapplex#
Hi Rainer,

What's the best way to "interact" with the service? I have the service running but I can't find the way to open my application and change some config parameters, for example.

Excuse me for my "stupid" question but I'm starting to use NSIS and I can't find a solution for this issue.

Thanks in advance.
Speed78#
Re: Re: Re: v1.24 - WZCSVC problem

Hi aerDNA,

Originally posted by aerDNA
When stopped manually, everything's ok (takes about 2 sec). With SimpleSC 1.23 it's also fine. The problem is with v1.24-1.25. Starting the service works ok in new versions, although it takes several seconds longer than with 1.23.
I´ve changed the code stop-service in version 1.24 because on some conditions the service doesn´t stop correctly. So please can you give me the following information:

Please try to stop the service via the plugin >= 1.24. Open during stopping the service the service control manager and take a look to the service at the "Status"-column. Which state do you see? "Stopping..."?

Did the service have dependencies?

Kind regards

Rainer
Speed78#
Hi pineapplex,

Originally posted by pineapplex
Hi Rainer,

What's the best way to "interact" with the service? I have the service running but I can't find the way to open my application and change some config parameters, for example.

Excuse me for my "stupid" question but I'm starting to use NSIS and I can't find a solution for this issue.

Thanks in advance.
there are several solutions to communicate with a service. You can use a TCP/IP socket, named pipes or shared memory. This depends on your knowledge about this methods and your service requirements.

Use this topics (TCP/IP socket, named pipes or shared memory) to get more addionally informations for you programming language.

Kind regards

Rainer
Speed78#
Re: Re: Re: Re: v1.24 - WZCSVC problem

Hi aerDNA,

Originally posted by Speed78
Hi aerDNA,



I´ve changed the code stop-service in version 1.24 because on some conditions the service doesn´t stop correctly. So please can you give me the following information:

Please try to stop the service via the plugin >= 1.24. Open during stopping the service the service control manager and take a look to the service at the "Status"-column. Which state do you see? "Stopping..."?

Did the service have dependencies?

Kind regards

Rainer
I can reproduce your behaviour now and I will fix asap.

Kind regards

Rainer
Speed78#
New Version 1.26

Hi,

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

- Fixed wait for status bug on starting, stopping, pausing or continuing a service

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

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

Kind regards

Rainer
aerDNA#
Glad I could help. There are several service plugins but personally I prefer yours. I used it to make a little util aimed specifically at managing WZC / WLAN Autoconfig. Compiled with v1.26 and works like a charm. So thank you.
kalix11#
I tried using V1.26 to Set Logon account info for the Service and was not able to do it. When I visited your plugin page at http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin and found there is a note: The function "SetServiceLogon" only works if the servicetype is "SERVICE_WIN32_OWN_PROCESS"

Would you please explain a little more about this servicetype? And how do I check and adjust the servicetype? Thanks a lot.
Speed78#edited
Hello kalix11,

Originally posted by kalix11
I tried using V1.26 to Set Logon account info for the Service and was not able to do it. When I visited your plugin page at http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin and found there is a note: The function "SetServiceLogon" only works if the servicetype is "SERVICE_WIN32_OWN_PROCESS"
At the moment there is no possibility to get or set the service type. I would add these functions in the next version of the plugin.

If you create a service on your own you should know the service type.

Some useful link about the service type can be found here:

http://msdn.microsoft.com/en-us/library/ms681987(VS.85).aspx

See "lpServiceStartName [in, optional]" - lpServiceStartName is the username!

Kind regards

Rainer
kalix11#
Thank you for your reply. I checked my service using some 3rd party tool and found the servicetype is SERVICE_WIN32_OWN_PROCESS. Can you think of any reason why SetServiceLogon is not working? I tried username with ".\" or without ".\", all the same results. Or should I first grant LogonAsService privilege to the user account before I call SetServiceLogon?
Speed78#
Hi kalix11,

Originally posted by kalix11
Thank you for your reply. I checked my service using some 3rd party tool and found the servicetype is SERVICE_WIN32_OWN_PROCESS. Can you think of any reason why SetServiceLogon is not working? I tried username with ".\" or without ".\", all the same results. Or should I first grant LogonAsService privilege to the user account before I call SetServiceLogon?
You don´t need this "\."-prefix in version 1.26 and you don´t need grant service logon before SetServiceLogon.

Make sure that the user exists. If the user exists please please check the error result using the GetErrorMessage-Function like in this example:

SimpleSC::SetServiceLogon "MyService" "MyServiceUser" "MyServiceUserPassword"
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
IntCmp $0 0 Done +1 +1
Push $0
SimpleSC::GetErrorMessage
Pop $0
MessageBox MB_OK|MB_ICONSTOP "SetServiceLogon fails - Reason: $0"
Done:

Kind regards

Rainer
kalix11#
Thanks for the quick reply. I used your code and found out the reason is : The account name is invalid or does not exist, or the password is invalid for the account name specified.

However, I'm pretty sure I'm using an existing account and provided right password. I also create a test account and it still failed. Any thoughts on it?
Speed78#
Hi,

Originally posted by kalix11
Thanks for the quick reply. I used your code and found out the reason is : The account name is invalid or does not exist, or the password is invalid for the account name specified.

However, I'm pretty sure I'm using an existing account and provided right password. I also create a test account and it still failed. Any thoughts on it?
Can you give me the account name? Is this a domain account, then you have to use domain\user - syntax!? Does the name contains some specail characters? Remark: The plugin is not a unicode plugin!

Kind regards

Rainer
kalix11#
The test account is just called "test" with password the same. Nothing fancy, just a proof of concept.
Speed78#
Hi,

Originally posted by kalix11
The test account is just called "test" with password the same. Nothing fancy, just a proof of concept.
I can´t reproduce it. I have created on Windows Vista and Windows XP a local user called "test" with the same password and used the function without any problems!

So please can you give me the following informations:

1. Which NSIS Version do you use?
2. Which OS + SP + Language are you using?
3. Please can you post your NSIS setup lines here. If possible can you send me a sample setup to rainer@speed-soft.de

Kind regards

Rainer
kalix11#
Thank you so much for your time. I'll try to clean up other stuffs and give you only what it needs to reproduce the error and send you the email. Thanks again.

BTW, the service was created using a java service wrapper from http://wrapper.tanukisoftware.org/. I don't know whether this would make any difference.
kalix11#
Rainer is the MAN! Eventually there was an error in my code not passing the correct username and password. No wonder it would fail. There is nothing wrong with the plug-in.

Rainer rocks!!!
disruptor108#
Originally posted by elllit
Hi,

first: sorry for the delay in answering your reply.



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
I understand that this post may be over a year old, but I was having the same issue. When installing my service it would throw a 1053 error when trying to start.

I found the solution was to register the service:

ExecWait '"$INSTDIR\${PRODUCT_NAME}\Product.exe" /service'
After doing this, SimpleSC::StartService worked just fine.
Speed78#
Hello,

Originally posted by disruptor108
I found the solution was to register the service:

ExecWait '"$INSTDIR\${PRODUCT_NAME}\Product.exe" /service'
After doing this, SimpleSC::StartService worked just fine.

the problem of elllit was that there exists services which depends on his service. Because of that the service doesn´t start.

I think your problem was that your service wasn´t installed. Because of this your service doesn´t start. You can use your method which works of course or you can use the method SimpleSC::InstallService which is the general method for every service. However, you need to install the service first and after this you can start the service.

Kind regards

Rainer
janvi#
Hi Rainer,

I m new to NSIS Script and I have been trying to install a Windows Service using your service plugin. I want to run a JAR file, rather than an exe, when the service starts.
The service gets installed but I m not able to get it started. Whenever the installed service is started an error pops up saying "Could not start MyService service on Local Computer. Error 193: 0xc1".
I know the fact that this error comes up if the application is not valid Win32 application but I dont find any issues with my attempt of installation.
Using NSIS script I m placing (installing) the required files into installation directory and using service plugin I install it where the <binary_path> value in SimpleSC::InstallService points to the JAR file placed in the installation directory.
Can you please guide me?

Thank You,
Janvi
MSG#
I'd expect you would need to execute java with the jar as a parameter. Jar files aren't executable by themselves.