Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   How to start stop uninstall services BASED on IF services are started, stopped, etc? (http://forums.winamp.com/showthread.php?t=206179)

vbgunz 28th January 2005 07:21

How to start stop uninstall services BASED on IF services are started, stopped, etc?
 
I need to communicate with services and communication is very dependent on the services current state. e.g. There is no point in trying to start a started service. No point in trying to stop a stopped service. No point in trying to uninstall a nonexistent service...

I've been pulling my hair trying hard on this. I've download the services.dll by sunjammer I believe. I've downloaded the NSIS service lib and worked with that. Both choices are no go. Sunjammers solution works with MessageBoxes BUT how do I use that to my advantage? How do I say IF service is installed GOTO Is service running? IF service is running please stop it. IF service is installed but not running please uninstall.

Man, I tried clear errors, IfErrors and a bunch of other stuff and cant quite get any thing to work. This is something I tried in so many different variations but give me no cigar :(
code:
Section
ClearErrors
services::IsServiceRunning 'MyService'
Pop $0
IfErrors skip1
DetailPrint "one sleeping... Stopping MyService"
nsExec::ExecToLog '"C:\Program Files\rock\paper\scissor.exe" -stop'
Sleep 9000
skip1:

ClearErrors
services::IsServiceInstalled 'MyService'
Pop $0
IfErrors skip2
DetailPrint "one sleeping... Removing MyService"
nsExec::ExecToLog '"C:\Program Files\rock\paper\scissor.exe" -remove'
Sleep 9000
skip2:

ClearErrors
services::IsServiceRunning 'MyService'
Pop $0
IfErrors 0 skip3
DetailPrint "Second sleeping... Stopping MyService"
nsExec::ExecToLog '"C:\Program Files\rock\paper\scissor.exe" -stop'
Sleep 9000
skip3:

ClearErrors
services::IsServiceInstalled 'MyService'
Pop $0
IfErrors 0 skip4
DetailPrint "Second sleeping... Removing MyService"
nsExec::ExecToLog '"C:\Program Files\rock\paper\scissor.exe" -remove'
Sleep 9000
skip4:
SectionEnd


Any body have any ideas? I much rather work with the plugin by sunjammer than work with the other script. I could in no way get the other script to work. I couldn't even get an error out of it :( Can someone please help. Thanks!

vbgunz 28th January 2005 08:44

I've solved it ;)
 
I've solved it... I was going to sleep before posting that last message but I could never really sleep without solving a problem from the night before ;)

Anyway, I promise to post my solution tomorrow for those looking on seeing about how I did it.

Joel 28th January 2005 13:18

[off topic]
Are you the same vbgunz from Abyss? :)
[/off topic]

vbgunz 28th January 2005 19:19

Hello Lobo. Yes, I am that vbgunz ;)

Here is how I solved the IF service exist do something or do something else. The following code is for use with the services plugin. I hope this helps :)
code:
Section
services::IsServiceRunning 'MyService'
Pop $0
StrCmp $0 Yes 0 no_MyService_running
DetailPrint "Preparing to Stop MyService"
nsExec::ExecToLog '"C:\Program Files\rock\paper\scissor.exe" -stop'
Goto MyService_running_done

no_MyService_running:
DetailPrint "HOORAY!!! Skipped an unstarted service (MyService);)"
Goto MyService_running_done
MyService_running_done:

services::IsServiceInstalled 'MyService'
Pop $0
StrCmp $0 Yes 0 no_MyService_installed
DetailPrint "Preparing to Uninstall MyService"
nsExec::ExecToLog '"C:\Program Files\rock\paper\scissor.exe" -remove'
Goto MyService_installed_done

no_MyService_installed:
DetailPrint "HOORAY!!! Skipped uninstalling a ghost service (MyService);)"
Goto MyService_installed_done
MyService_installed_done:
SectionEnd



All times are GMT. The time now is 05:42.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.