#27 install/unistall windows service

open
nobody
None
5
2005-09-27
2005-09-27
f_spirit
No

I didn't find any task capable of intalling/uninstalling
windows services, which can be useful in several
situations. It' would be nice to have one. If i haven't
searched well, and there is such a task, please let me
khow.

Discussion

  • David Keaveny
    David Keaveny
    2006-07-21

    Logged In: YES
    user_id=152545

    I'm not aware of one either, so I use the following:

    <property name="installer.exe"
    value="${framework::get-framework-directory(nant.settings.currentframework)}\InstallUtil.exe"
    />

    <if test="${service::is-installed('MyWindowsService', '.')}">
    <exec
    commandline="/u MyWindowsService.exe"
    program="${installer.exe}"
    failonerror="false" />
    </if>

    The ${service::is-installed} function was introduced with
    0.85-rc4, so make sure you're fully up-to-date. The
    InstallUtil.exe program will automatically shut down the
    service if it is running, but you can always use the
    ${service::is-running} function together with the
    <servicecontroller> task to do it yourself.