Speed78
27th May 2009 22:48 UTC
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
disruptor108
1st July 2009 23:02 UTC
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. :confused:
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
2nd July 2009 17:12 UTC
Hello,
Quote:
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
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.
|
janvi
11th November 2009 13:43 UTC
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
11th November 2009 14:40 UTC
I'd expect you would need to execute java with the jar as a parameter. Jar files aren't executable by themselves.
janvi
12th November 2009 06:28 UTC
Hi MSG,
Thank you for replying. I tried what you said but it turned out to be a vain attempt. It's still not working. I guess the problem is not because of the JAR file.
I tried a different scenario to check if the JAR file is causing the problem. I tried to run notepad.exe as a service. This time a different error message popped up saying "Error 1053: The service didn't respond in timely fashion."
I have kept the script as simple as possible so that it remains less error prone.
Following is the script; please guide me if you find anything wrong:
<Script>
Name "TestService"
OutFile "TestService.exe"
InstallDir '$PROGRAMFILES\TestService'
SetCompress Auto
SetDateSave On
SetDataBlockOptimize On
SetOverwrite on
Section
SetOutPath $INSTDIR
File 'F:\Projects\JavaService.jar'
File 'F:\Projects\notepad.exe'
# SimpleSC::InstallService [name_of_service] [display_name] [service_type] [start_type]
# [binary_path] [dependencies] [account] [password]
SimpleSC::InstallService "TestService" "TestService" "16" "2"\
"$INSTDIR\JavaService.jar" "" "" ""
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
detailprint $0
# Start service
SimpleSC::StartService "TestService"
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
detailprint $0
</Script>
I dont understand what's wrong. Please help..
Thank You,
Janvi
janvi
12th November 2009 09:57 UTC
Hi,
Just some update.. I converted my JAR file into an exe using Jar2Exe tool. Now, using the same script I m able to run this exe as Windows Service. Any clue??
Thank You,
Janvi
janvi
15th November 2009 13:51 UTC
Hi..
Can anyone please guide me to solve the problem i'm facing?
Any help will be greatly appreciated.
Thank You,
Janvi
jpderuiter
15th November 2009 14:08 UTC
Since a service has to communicate with the OS (like "I'm still running"), I think it's not possible to install a jar file as service.
See the following for more info / what you can try:
http://edn.embarcadero.com/article/32068
http://www.coderanch.com/t/429680/Ge...jar-as-Windows
yudyzhao
4th February 2010 17:15 UTC
I has another issue with SimpleSC.dll. I installed the Unicode NSIS, then SimpleSC::ServiceIsRunning always return the service status is stopped (0) no matter my service is running or not.
Speed78, is there Unicode SimpleSC plug-in available? So urgent need this.
jpderuiter
4th February 2010 20:13 UTC
As far as I know SimpleSC is not available in Unicode.
As a workaround to find if a service is running you can use:
!include "WordFunc.nsh"
Var Service
.
.
.
; inside function / section
StrCpy $Service "ServiceName"
Push "ExecDos::End" # Add a marker for the loop to test for.
ExecDos::exec /TIMEOUT=2000 /TOSTACK 'sc.exe query "$Service"' "" ""
Pop $0 # return value
StrCmp $0 0 0 NotRunning
## Loop through stack.
StrCpy $2 0
Loop:
Pop $1
StrCmp $1 "ExecDos::End" ExitLoop
${WordFind} "$1" "RUNNING" "*" $3
Intcmp $3 0 NotFound NotFound
IntOp $2 $2 + 1
NotFound:
StrCpy $3 "0"
Goto Loop
ExitLoop:
IntCmp $2 0 NotRunning NotRunning Running
NotRunning:
DetailPrint "$Service is not running"
Goto End
Running:
DetailPrint "$Service is running"
Goto End
End:
Hope this helps.
(The ExecDos plugin is available for unicode:
http://forums.winamp.com/showthread.php?threadid=181442)
yudyzhao
5th February 2010 09:38 UTC
Thanks for help.
But ExceDos (Unicode version)cannot find the running windows service as well... no clue what wrong with it
:eek:
jpderuiter
5th February 2010 09:43 UTC
OK.
Well, I didn't test this in Unicode, but what's the output of ExecDos?
(Add DetailPrint "$1" after Pop $1 in the loop to see what it is)
Ebi70
12th July 2010 08:15 UTC
Problem after deleting and then Install a service
Hello together,
I have following problem with the simplesc plugin.
I install my service with installutil of .net, because when I try to install with simplesc, then the services will hnot start, I think this is because that the dependencies are not correct updated.
Anyway, when I install my service with installutil, update then the logon with:
SimpleSC::SetServiceLogon "<name>" "$USER_NAME" "$USER_PASSWORD"
everything works fine.
Then I start my installer again and update my installation.
Within the "Function preuninstall_function" i stop the services if they are running with:
SimpleSC::StopService "<name>"
and then remove the service with:
SimpleSC::RemoveService "<name>" or again with
installutil of .net (makes no sense what I use, the service is removed from the list),
but when I now try to reinstall the service again in my Section like explained above,
the service is installed, but the user update will fail:
SimpleSC::SetServiceLogon "<name>" "$USER_NAME" "$USER_PASSWORD"
Any ideas?
Thanks,
Ebi70
Speed78
20th July 2010 10:01 UTC
Hello,
sry for this answer-delay. I don't get any message that somebody posts in this thread and I don't know why :(.
Originally posted by Ebi70
Hello together,
I have following problem with the simplesc plugin.
I install my service with installutil of .net, because when I try to install with simplesc, then the services will hnot start, I think this is because that the dependencies are not correct updated.
1. Please post the sc.exe command and the SimpleSC::InstallService command which you are using.
2. After using sc.exe and SimpleSC::InstallService, please check the dependencies in the Windows service manager.
3. Please post the dependencies of your service.
Originally posted by Ebi70
but when I now try to reinstall the service again in my Section like explained above,
the service is installed, but the user update will fail:
SimpleSC::SetServiceLogon "<name>" "$USER_NAME" "$USER_PASSWORD"
Please use the GetErrorMessage Function to get the error. In the documentation you can find an example how to use it.
Kind regards
Rainer
Speed78
14th September 2010 12:36 UTC
New Version 1.28
Hi,
I've released a new version of the NSIS Simple Service Plugin. There are two new functions SimpleSC::GetServiceFailure and SimpleSC::SetServiceFailure. The function SimpleSC::StopService has now an addional argument to wait for file release if you would overwrite the binary file.
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.
Special thanks to Rogier for this great donation. He makes this changes possible.
Best regards
Rainer
mabian
12th October 2010 16:30 UTC
Hello, I'm having problems with this plugin, 1.28.
StrCpy$P_ServiceName
"EcoManager_$P_ServiceID"
SimpleSC::ExistsService"$P_ServiceName"
Pop$0;returnsanerrorcodeiftheservicedoesn´texists(<>0)/serviceexists(0)
MessageBoxMB_OK"Servizio$P_ServiceNameesiste?$0"
Even though the service name is built correctly and it doesn't exists, the messagebox says $0 value is 0.
Maybe is it something about unicode (trying it on XP SP3)?
Thank you,
Mario
Speed78
12th October 2010 17:26 UTC
Dear mabian,
if your service name contains Unicode characters you will get problems. This version of the service plugin doesn't support Unicode.
1. Please enter SimpleSC::ExistsService your service name and don't use a variable (only for testing).
2. Try to use the ExistsService-Method with an other service. If this works I asume that it depends on your servicename + Unicode.
3. Please use the GetErrorMessage Method to get error text.
Please let me know your results.
Kind regards
Rainer
mabian
12th October 2010 17:48 UTC
This fragment:
SimpleSC
::ExistsService"Dnscache"
Pop$0;returnsanerrorcodeiftheservicedoesn´texists(<>0)/serviceexists(0)
MessageBoxMB_OK"$0"
Push$0
SimpleSC::GetErrorMessage
Pop$0
MessageBoxMB_OK|MB_ICONSTOP"Message:$0"
Produces a few japanese chars in the first message box and a longer japanese/chinese string in the second...
- Mario
Same with an unexisting service name.
Thanks,
Mario
Speed78
12th October 2010 18:35 UTC
Dear mabian,
you can only use GetErrorMessage if an error exists e.g.
SimpleSC
::ExistsService"Dnscache"
Pop$0;returnsanerrorcodeiftheservicedoesn´texists(<>0)/serviceexists(0)
MessageBoxMB_OK"$0"
IntCmp$00Done+1+1
Push$0
SimpleSC::GetErrorMessage
Pop$0
MessageBoxMB_OK|MB_ICONSTOP"Message:$0"
Done:
nethertheless this is not the problem. Are you using the Unicode-Version of NSIS? If yes please try it with the Non-Unicode. I just tried it with the Non-Unicode Version of NSIS and it works for me.
Kind regards
Rainer
mabian
12th October 2010 21:50 UTC
Confirmed: the ANSI version of NSIS works as expected.
I thought the dll would work with Unicode NSIS as long as no unicode strings were used.
Thank you very much!
- Mario
nv_rajanikanth
13th October 2010 12:17 UTC
Hi
Thanks for this plug-in. Now i am able to install/start/stop...of 'my service' through this.
but i am not able to see this in the 'services.msc'.
please let me know how to list this 'my service' into 'services.msc', so that later on i can stop/start/restart manually.
Thanks,
Rajanikanth
Speed78
13th October 2010 13:44 UTC
Dear Rajanikanth,
if you can install/start/stop the service your service should be displayed in the ServiceManager (services.msc) or I don't understand you correctly!?
Kind regards
Rainer
mabian
13th October 2010 13:57 UTC
Rajanikanth,
if you have services.msc already open while the installer adds the service, you have to press F5 to make it update the service list.
Installing a service adds it to the list here.
- Mario
hnedka
22nd December 2010 17:53 UTC
Hi, I have created a workaround to make it work with Unicode. You first need to enter this into your code:
PHP Code:
!defineUnicode2Ansi"!insertmacroUnicode2Ansi"
!macroUnicode2AnsiStringoutVar
System::Call'kernel32::WideCharToMultiByte(i0,i0,w"${String}",i-1,t.s,i${NSIS_MAX_STRLEN},i0,i0)i'
Pop"${outVar}"
!macroend
And then you call SimpleSC functions like this:
PHP Code:
${Unicode2Ansi}"my_service_short_name"$R0
SimpleSC::StopService"$R0"0
Pop$0
It will obviously
not work with chars, that are really Unicode (like Chinese) and probably also with everything non-english or non-local-language, but in standard situations, it should work. If there are any problems, let me know in this thread.
Speed78
16th April 2011 15:56 UTC
New Version 1.29
Hi,
I've released a new version of the NSIS Simple Service Plugin. There are four new functions:
- GetServiceFailureFlag
- SetServiceFailureFlag
- GetServiceDelayedAutoStartInfo
- SetServiceDelayedAutoStartInfo
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
19th June 2011 18:08 UTC
SimpleSC checks whether the service is stopped before calling DeleteService. This is fine in normal circumstances, but some services cannot be stopped (they have no handler). I'd rather SimpleSC just went ahead and called DeleteService anyway, where in such cases the service will be deleted on reboot (i.e. DeleteService returns 1072). If you don't want to change the current behaviour, at least add a /force switch or something which ignores the state of the service.
Stu
Speed78
19th June 2011 21:10 UTC
Hey Stu,
I think the best way is to do it like windows does it in the "sc delete" command. Therefore I will remove the "Stopped"-check in the code. I will change it within the next week.
Kind regards
Rainer
rijukk
6th July 2011 13:25 UTC
[wait_for_file_release]
Hi Rainer,
Originally posted by Speed78
I've released a new version of the NSIS Simple Service Plugin. There are two new functions SimpleSC::GetServiceFailure and SimpleSC::SetServiceFailure. The function SimpleSC::StopService has now an addional argument to wait for file release if you would overwrite the binary file.
As you said, I used SimpleSC::StopService with "wait_for_file_release" flag, since i need to overwrite the binary file.
Sometimes our services take longer time,>30sec, to stop in that case
SimpleSC::StopService "<My Service Name>" 1
Will return with an error# 1053 (The service did not respond to the start or control request in a timely fashion).
Currently I am over coming this using loop and check status logic. below is my code snippet
SimpleSC::StopService "<My Service Name>" 1
; My service take more than 30sec to stop sometimes since it is doing some file processing
Pop $0
;"1053 error (The service did not respond to the start or control request in a timely fashion)
Goto CheckServiceStateNoSleep
LoopAgain:
DetailPrint "Waiting for service to stop..."
Sleep 2000
CheckServiceStateNoSleep:
SimpleSC::GetServiceStatus "<My Service Name>"
Pop $0
Pop $1
IntCmp $1 1 ServiceStopped LoopAgain LoopAgain
ServiceStopped:
;Service Exe replacement step here
Is there any better alternatives?
Thank you,
Riju
Speed78
7th July 2011 17:30 UTC
Hi Riju,
if your service need more than 30 seconds I think you are using the registry setting ServicePipeTimeout!? Otherwise you should get a windows message e.g. if you are stopping the service via Service Manager.
So I can do the following:
1. I can wait until the service controller gave me the result information after an action (e.g. stopped, timeout, etc.). The disadvantage can be that I'm waiting forever and the setup seems to hang.
2. I can add a wait timeout parameter in the function. The disadvantage is that the timeout doesn't depend on the windows timeout.
However, I think I need to check it and I will try to change it within the next release. I have another task on my todo list for Stu, but at the moment my work in the company is very stressful. Therefore it can take a time.
Kind regards
Rainer
rijukk
8th July 2011 04:18 UTC
Hi Rainer,
I appreciate you for taking time from your busy schedule to reply our queries.. Thank you!!
Originally posted by Speed78
So I can do the following:
1. I can wait until the service controller gave me the result information after an action (e.g. stopped, timeout, etc.). The disadvantage can be that I'm waiting forever and the setup seems to hang.
2. I can add a wait timeout parameter in the function. The disadvantage is that the timeout doesn't depend on the windows timeout.
I think,
wait timeout parameter in the function will do the trick. If timeout is 0, it will wait till the service stop properly.
I see it rather an
advantage than a disadvantage, In a sense you are providing an optional parameter to override the default windows timeout. That is always an advantage :)
Thank you very much,
Riju
aerDNA
16th July 2011 11:59 UTC
@ZvyaginzevaE:
Googled what you're looking for and seems it can be obtained easily. But you completely missed the forum, this one has nothing to do with cars.
Speed78
28th July 2011 19:15 UTC
NSIS 1.30 Beta
Dear all,
in the attachment you can find a Beta version of the new NSIS plugin. This version contains these new functions:
The following functions got a new "Timeout" parameter:
- SimpleSC::StartService
- SimpleSC::StopService
- SimpleSC::PauseService
- SimpleSC::ContinueService
- SimpleSC::RestartService
The function SimpleSC::RemoveService doesn't stop the service now. If you need this functions please use the SimpleSC::StopService before you remove the service.
It would be great if you can check this new version. Any feedback will be welcome.
Kind regards
Rainer
Speed78
15th August 2011 22:13 UTC
New Version 1.30
Dear all,
no news are good news. Therefore I released a new version of the NSIS Simple Service Plugin.
There are four new functions:
- The function SimpleSC::RemoveService doesn't stop the service now. If you need this functions please use the SimpleSC::StopService before you remove the service.
- The following functions got a new "Timeout" parameter:
- SimpleSC::StartService
- SimpleSC::StopService
- SimpleSC::PauseService
- SimpleSC::ContinueService
- SimpleSC::RestartService
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
rijukk
21st September 2011 12:52 UTC
Hi Rainer,
I really appreciate you for coming up with "timeout parameter" as requested. However I am sorry, currently I am away from the installer project; hoping to back soon too. I will definitely do my aprt of testing and let you know my experience.
btw, is there any infinite timeout value like "-1" or "0"?
Thank you,
Riju
- NSIS Discussion
- NSIS Simple Service Plugin
Archive: NSIS Simple Service Plugin
sr164w
18th January 2012 08:25 UTC
Can I use this plugin in for commercial use of my installer:confused:?
T.Slappy
19th January 2012 06:22 UTC
By default all plug-ins can be used in commercial installers.
If it is not strictly prohibited in plug-in readme then feel free to use it.
dixonich
10th December 2012 10:44 UTC
Hello! My problem. Services plug-in not work! Help please!Service does not start!
!define PRODUCT_NAME "MyApp"
!define PRODUCT_VERSION "19"
!define pkgdir "C:\Swe"
!include "MUI.nsh"
SetCompressor /SOLID lzma
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "Russian"
Name "${PRODUCT_NAME}"
Caption "Установка ${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "${PRODUCT_NAME}-${PRODUCT_VERSION}.exe"
ShowInstDetails show
Section
SetOutPath "C:\"
File "${pkgdir}\SystemTrayDemo.exe"
SimpleSC::InstallService "ServiceStartD" "Testing123D" "16" "2" "C:\SystemTrayDemo.exe" "" "" ""
SimpleSC::StartService "ServiceStartD" "" 30
SectionEnd
Anders
10th December 2012 15:01 UTC
Can you start it if you run services.msc (Computer management)?
Speed78
10th December 2012 19:23 UTC
Originally posted by dixonich
Hello! My problem. Services plug-in not work! Help please!Service does not start!
!define PRODUCT_NAME "MyApp"
!define PRODUCT_VERSION "19"
!define pkgdir "C:\Swe"
!include "MUI.nsh"
SetCompressor /SOLID lzma
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "Russian"
Name "${PRODUCT_NAME}"
Caption "Установка ${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "${PRODUCT_NAME}-${PRODUCT_VERSION}.exe"
ShowInstDetails show
Section
SetOutPath "C:\"
File "${pkgdir}\SystemTrayDemo.exe"
SimpleSC::InstallService "ServiceStartD" "Testing123D" "16" "2" "C:\SystemTrayDemo.exe" "" "" ""
SimpleSC::StartService "ServiceStartD" "" 30
SectionEnd
Which error mesage do you got (GetErrorMessage)? Are you using the unicode version of NSIS?
Kind regards
Rainer
nuoyantaizi
6th October 2013 08:34 UTC
Hi,Speed78
Nice to meet you.I have a problem when use NSIS Simple Service Plugin to install a windows service named "Apache".
When i use "SimpleSC::InstallService ...." ,the service is installed ok,but it can not start,the error is "required components not installed".
I have a try to use "apache/bin/httpd -k install",i saw the dependences are "AFD",and "TCP/IP Protocal Driver / IPSEC driver".
So,how can i use simplesc to install this apache ?
By the way,StartSercie,StopService need 30 seconds,that's so long! My production need to install 4 service on user's computer,so that's need too much time! Can you tell me if the SimpleSC can do this like "sc start httpd","sc stop httpd" ?
Best Regards
From your chinese friend :)
jpderuiter
7th October 2013 23:45 UTC
When i use "SimpleSC::InstallService ...." ,the service is installed ok,but it can not start,the error is "required components not installed".
I have a try to use "apache/bin/httpd -k install",i saw the dependences are "AFD",and "TCP/IP Protocal Driver / IPSEC driver".
So,how can i use simplesc to install this apache ?
Use "AFD/IPSec/Tcpip" as dependencies in the InstallService command (see
http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin)
nuoyantaizi
10th October 2013 15:28 UTC
Thank you very much
Originally posted by jpderuiter
Use "AFD/IPSec/Tcpip" as dependencies in the InstallService command (see http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin)
To jpderuiter,
thank you very much!
I have a try what you said,the dependences are installed successfully! thanks again!
But tha apache software can not start yet.i don't know why,i think the software has its own process when use "-k install".but i still thanks you told me how to use the dependence parameter:)
Another question,do you know how to install a .NET service except using "installutil.exe" ?
I have a .exe that developed by .net framework 4.0,i try to use SimpleSC to install ,and i failed,i must to use the .NET install tool "installutil.exe" to install it.
Ah,do you understand what i said ? :) ,i am sorry about my english.
but,all of these are ok! i have write a .exe instead of that one.
Thanks again!
i have to improve my english now ,today i met a German teacher,thanks to God,there is a senior student there ,and she can speak german very well~:)
Afrow UK
10th October 2013 17:00 UTC
You only need to use installutil.exe if the .NET service uses the ServiceInstaller/ServiceProcessInstaller classes to define its install configuration. If you just create the service and only extend the ServiceBase class then you can install it using the normal Windows APIs (i.e. SimpleSC will work).
Stu