Announcement

Collapse
No announcement yet.

How to start stop uninstall services BASED on IF services are started, stopped, etc?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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!

  • #2
    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.

    Comment


    • #3
      [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.

      Comment


      • #4
        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

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎