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
NSIS Simple Service Plugin
142 posts
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
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
Hi..
Can anyone please guide me to solve the problem i'm facing?
Any help will be greatly appreciated.
Thank You,
Janvi
Can anyone please guide me to solve the problem i'm facing?
Any help will be greatly appreciated.
Thank You,
Janvi
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
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
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.
Speed78, is there Unicode SimpleSC plug-in available? So urgent need this.
As far as I know SimpleSC is not available in Unicode.
As a workaround to find if a service is running you can use:
(The ExecDos plugin is available for unicode:
http://forums.winamp.com/showthread.php?threadid=181442)
As a workaround to find if a service is running you can use:
Hope this helps.!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:
(The ExecDos plugin is available for unicode:
http://forums.winamp.com/showthread.php?threadid=181442)
Thanks for help.
But ExceDos (Unicode version)cannot find the running windows service as well... no clue what wrong with it
😱
But ExceDos (Unicode version)cannot find the running windows service as well... no clue what wrong with it
😱
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)
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)
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
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
Hello,
sry for this answer-delay. I don't get any message that somebody posts in this thread and I don't know why 🙁.
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.
Kind regards
Rainer
sry for this answer-delay. I don't get any message that somebody posts in this thread and I don't know why 🙁.
1. Please post the sc.exe command and the SimpleSC::InstallService command which you are using.Originally Posted by Ebi70 View PostHello 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.
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.
Please use the GetErrorMessage Function to get the error. In the documentation you can find an example how to use it.Originally Posted by Ebi70 View Postbut 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"
Kind regards
Rainer
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
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
Hello, I'm having problems with this plugin, 1.28.
Maybe is it something about unicode (trying it on XP SP3)?
Thank you,
Mario
StrCpy $P_ServiceName "EcoManager_$P_ServiceID"
SimpleSC::ExistsService "$P_ServiceName"
Pop $0 ; returns an errorcode if the service doesn´t exists (<>0)/service exists (0)
MessageBox MB_OK "Servizio $P_ServiceName esiste? $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
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
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
This fragment:
- Mario
Same with an unexisting service name.
Thanks,
Mario
SimpleSC::ExistsService "Dnscache"
Pop $0 ; returns an errorcode if the service doesn´t exists (<>0)/service exists (0)
MessageBox MB_OK "$0"
Push $0
SimpleSC::GetErrorMessage
Pop $0
MessageBox MB_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
Dear mabian,
you can only use GetErrorMessage if an error exists e.g.
Kind regards
Rainer
you can only use GetErrorMessage if an error exists e.g.
SimpleSC::ExistsService "Dnscache"
Pop $0 ; returns an errorcode if the service doesn´t exists (<>0)/service exists (0)
MessageBox MB_OK "$0"
IntCmp $0 0 Done +1 +1
Push $0
SimpleSC::GetErrorMessage
Pop $0
MessageBox MB_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
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
I thought the dll would work with Unicode NSIS as long as no unicode strings were used.
Thank you very much!
- Mario
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
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
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
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
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
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
Hi, I have created a workaround to make it work with Unicode. You first need to enter this into your code:
!define Unicode2Ansi "!insertmacro Unicode2Ansi"
!macro Unicode2Ansi String outVar
System::Call 'kernel32::WideCharToMultiByte(i 0, i 0, w "${String}", i -1, t .s, i ${NSIS_MAX_STRLEN}, i 0, i 0) i'
Pop "${outVar}"
!macroend And then you call SimpleSC functions like this:${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.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
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
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
Stu
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
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
[wait_for_file_release]
Hi Rainer,
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
Thank you,
Riju
Hi Rainer,
As you said, I used SimpleSC::StopService with "wait_for_file_release" flag, since i need to overwrite the binary file.Originally Posted by Speed78 View PostI'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.
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
Is there any better alternatives?
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
Thank you,
Riju
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
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
Hi Rainer,
I appreciate you for taking time from your busy schedule to reply our queries.. Thank you!!
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
I appreciate you for taking time from your busy schedule to reply our queries.. Thank you!!
I think, wait timeout parameter in the function will do the trick. If timeout is 0, it will wait till the service stop properly.Originally Posted by Speed78 View Post
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 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
@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.
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.
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:
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
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
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:
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
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
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
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