Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 15th November 2007, 20:17   #1
GregL
Junior Member
 
Join Date: Aug 2007
Posts: 11
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
GregL is offline   Reply With Quote
Old 15th November 2007, 21:24   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Why not use some hidden sections?
code:
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
Afrow UK is offline   Reply With Quote
Old 19th November 2007, 14:23   #3
GregL
Junior Member
 
Join Date: Aug 2007
Posts: 11
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:
code:
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.)
GregL is offline   Reply With Quote
Old 19th November 2007, 18:00   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 20th November 2007, 00:39   #5
Lazik
Junior Member
 
Join Date: Nov 2007
Posts: 1
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..
Lazik is offline   Reply With Quote
Old 20th November 2007, 07:48   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Use the services plugin.

Stu
Afrow UK is offline   Reply With Quote
Old 20th November 2007, 13:25   #7
GregL
Junior Member
 
Join Date: Aug 2007
Posts: 11
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.
GregL is offline   Reply With Quote
Old 20th November 2007, 16:35   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Maybe if you posted your code we could see exactly what the problem is. Hidden sections are simply hidden from the components page.

Quote:
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
Afrow UK is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump