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

Reply
Thread Tools Search this Thread Display Modes
Old 28th January 2005, 08:21   #1
vbgunz
Senior Member
 
Join Date: Jun 2003
Posts: 284
Send a message via AIM to vbgunz
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 is offline   Reply With Quote
Old 28th January 2005, 09:44   #2
vbgunz
Senior Member
 
Join Date: Jun 2003
Posts: 284
Send a message via AIM to vbgunz
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.
vbgunz is offline   Reply With Quote
Old 28th January 2005, 14:18   #3
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,918
[off topic]
Are you the same vbgunz from Abyss?
[/off topic]


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.

Joel is offline   Reply With Quote
Old 28th January 2005, 20:19   #4
vbgunz
Senior Member
 
Join Date: Jun 2003
Posts: 284
Send a message via AIM to vbgunz
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

vbgunz 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