ghat
25th March 2009 18:31 UTC
Display message on main screen while performing ExecWait
Hi,
I am using MUI from the wizard in HM NSI edit. I need to stop a service before installing the main files and start the service back after installing the files.
Something like
ExecWait net stop service_name
//install the files
ExeWait net start service_name
I want to display the feed back message like "Stopping the service.." and "Starting the Service.." while waiting for the service to stop and start on the main Installation window. Is it possible.
Any help is appreciated. Hope I was clear.
Thanks in advance.
Animaether
25th March 2009 18:54 UTC
if this is something you do during intallation (e.g. from within a section), you could just use DetailPrint to put the message up with the rest of the progress messages. Alternatively, use one of the many banner type plugins such as 'animate' to pop up a little dialog before you call the 'net stop' command, and kill that dialog once execwait (or whatever you end up using) returns.
You may also want to have a look at this page regarding handling Services with NSIS:
http://nsis.sourceforge.net/How_do_I...heck_a_service
ghat
26th March 2009 15:33 UTC
Thanks I got that. Now I am trying to use NSIS_Simple_Service plugin since it seems a much better way to deal with services. But I am unable to capture the error. How do I check the return values?
" SimpleSC::GetServiceStatus "MyService"
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
Pop $1 ; return the status of the service"
I want to call SimpleSC to get current status of service. If it is already runnign I ignore or I start the service and if any error occurs I would display a message.
Animaether
26th March 2009 20:12 UTC
something like this...
!addplugindir "."
!addincludedir "."
!include "nsDialogs.nsh"
!include "winmessages.nsh"
!include "logiclib.nsh"
OutFile "test.exe"
Page Custom Test
Function Test
SimpleSC::GetServiceStatus "WZCSVC" ; Wireless Zero Configuration
Pop $0
Pop $1
${If} $0 != 0
MessageBox MB_OK "An error occurred while attempting to get the service's status. The service may not exist."
${Else}
${Select} $1
${Case} 1
MessageBox MB_OK "SERVICE_STOPPED - The service is present but is currently stopped."
${Case} 2
MessageBox MB_OK "SERVICE_START_PENDING - The service is present and is currently waiting to be (re)started by the system."
${Case} 3
MessageBox MB_OK "SERVICE_STOP_PENDING - The service is present and is currently waiting to be stopped by the system."
${Case} 4
MessageBox MB_OK "SERVICE_RUNNING - The service is present and is currently started (running)."
${Case} 5
MessageBox MB_OK "SERVICE_CONTINUE_PENDING - The service is present and is currently waiting to be unpaused by the system."
${Case} 6
MessageBox MB_OK "SERVICE_PAUSE_PENDING - The service is present and is currently waiting to be paused by the system."
${Case} 7
MessageBox MB_OK "SERVICE_PAUSED - The service is present and is currently paused."
${EndSelect}
${EndIf}
FunctionEnd
Section
SectionEnd
Note that - in case you hadn't noticed - you need the name of the service, not its title. You can find the name via the services control panel, for example, in the service's properties panel.