Tcl as an NT Service

It's possible to run Tcl scripts as services under Microsoft Windows NT. Matt Newman has done a nice job of producing a wrapper, tclsvc that lets any event-driven Tcl script run as a service. Get it from

   http://www.sensus.org/tcl/index.htm 

or

   http://mkextensions.sf.net/ 

I find the latter to be a somewhat nicer distribution. I'm working on beefing up the documentation but I'm not sure where to put it. Give me a holler if you want a copy of my draft. -- Chris Nelson


Firedaemon [1 ] is an alternative.


Winserv is another alternative.


Activestate's Tcl Dev Kit provides a tool as well.

I'm using AS tcldev kit to wrap a service. I notice an issue when my service code does an open

   set pch [open "|$program" r]
   fileevent $pch readable readableproc

I notice readableproc is never called when run under the service. When the same code is run standalone it works fine. Anybody know what's going on here? - RT 20, November 2004


As of V2.0.9, TWAPI supports writing Windows services in Tcl as well. See A network echo Windows service using TWAPI.


If you are running a TCL script as a service and want to be able to name the service, the easiest way to do so is to copy the tclsh interpreter to the name of the service you want, and then interpret your script using that executable instead of tclsh.exe. -- Dave Fisher, 2005-01-02