Archive: Need suggestions with script flow to handle service updates


Need suggestions with script flow to handle service updates
Hello,

I've written a patch installer that stops a service, updates it (the EXE), and then restarts the service. The issue I have with it is the way MUI_PAGE_INSTFILES extracts files BEFORE following any of the directives within the main install section. So I have a function in front of it to stop the service, and it all works fine, but it then lacks output to the install window. There's no visual indication of what's going on. So I have it using the Banner plugin, but I didn't like the appearance of the popup window, and it still lacks output to the details window.

Is there a better way to handle the flow of this and make it look as professional as possible?

Thanks


Why not use some hidden sections?

Section `-Stop service`
DetailPrint `Stopping service...`
services::SendServiceCommand stop myservice
SectionEnd

Section `blah blah 1`
...
SectionEnd

Section `blah blah 2`
...
SectionEnd

Section `-Start service`
DetailPrint `Starting service...`
services::SendServiceCommand start myservice
SectionEnd
Stu

Thanks for the reply. I guess I learned something new with the hidden flags but it still exhibited the same behavior.

It gets to MUI_PAGE_INSTFILES and then runs the hidden sections, regardless of whatever order you put them in. Naturally, the file is still locked via the service and the update fails.

I also don't have whatever plugin you are referencing for the service controls. I'm running:

nsExec::ExecToLog "NET STOP MyService"

(I just upgraded to 2.33, and the main NSIS site is not working so well at the moment so I couldn't lookup the service plugin.)

Unless you have more than one InstFiles page your sections will be executed in the order that they are presented in your script. By the way, when you stop a service, locked files can still be locked for a number of seconds afterwards. You could just use a Sleep ####, or use this method (use the a (append) flag rather than w (write) on FileOpen though).

Stu


plugin
Hi,
I'm sorry to have this off-topic question, but It would help me If someone would answear..

Is there some plugin like used by Afrow UK in the example, or is it just some nonsense text just for example purpose?

And is there any way to get service status? I use "ExecWait mytest.bat $R0" - the batch file contains code
NET START | FIND "my service"
- It's a bit clumsy :/ works fine for Installer part, but doesn't work for Uninstaller part :/ I have no idea why..


Use the services plugin.

Stu


Thanks for your help, Stu, but some of this still doesn't make sense. For example, your first idea to use hidden sections. As far as I can tell, using that approach, the DetailPrint stuff goes off into limbo. If it's "hidden", where is that text printed? I'm using the MUI stuff and I'm not sure where to put the MUI_PAGE_INSTFILES in among your example. The irritating part of MUI_PAGE_INSTFILES is that it extracts your files as the very first thing it does. I'm not aware of that being configurable. I'm doing all of this in the name of good user experience. I want the little output window of the installer to show me everything that's going on. I had also tried the Banner plugin, but I didn't like the placement of text and presence of the installer icon (even though I have created my own icon). Aside from that, I have a fully-functioning installer.

Now for my nitpicks.
Stu's example makes use of some Service plugin with certain syntax. (Stu, where's a link to that?) I found NSIS_Service_Lib but the code in the wiki makes extreme use of span tags to color the code and cutting and paste creates a nightmare. Fortunately, you can edit the article and pull the code from the edit box. I found the Simple Service plugin which seemed similar. Apparently several coders all have a different approach to handling services as I've seen about 5 different ways to handle them now.


Maybe if you posted your code we could see exactly what the problem is. Hidden sections are simply hidden from the components page.

Stu's example makes use of some Service plugin with certain syntax. (Stu, where's a link to that?)
First link at the top of this page:
http://nsis.sourceforge.net/How_do_I...heck_a_service

Stu