in reply to Turn a perl script into a Win32 Service

Unfortunately, the CPAN module was last updated in 2001.

It's not like the services API have changed much if any since then. It may not have needed changes since then.

Does anyone know of an alternative to Win32::Daemon for making a program run as a service?

Microsoft provides the SrvAny tool.

And oddly enough, the link you provided for Win32::Daemon actually finds Win32::Daemon::Simple, not Win32::Daemon.

Update: s/SvrAny/SrvAny/ as per reply.

  • Comment on Re: Turn a perl script into a Win32 Service

Replies are listed 'Best First'.
Re^2: Turn a perl script into a Win32 Service
by dmorgo (Pilgrim) on Oct 09, 2008 at 17:16 UTC
    For the record, and to make the thread properly searchable, the name of the tool is Srvany, not Svrany. Note my comment has nothing to do with the capitalization. The problem is swapped letters. Again, I'm not trying to be a pedant; just getting 'Srvany' into the fossil record here. Of course the link was right, so nobody is going to get lost once they do find this thread.
Re^2: Turn a perl script into a Win32 Service
by Limbic~Region (Chancellor) on Oct 09, 2008 at 16:22 UTC
    ikegami,
    It's not like the services API have changed much if any since then. It may not have needed changes since then.

    Well, assuming the CPAN module from 2001 was mature and feature complete then, this might be ok. In looking at the docs from the one on CPAN and the docs on Dave's website, the module has changed quite a bit. In fact, the beta release for 5.10 has gone to XS. I only commented on the age of the CPAN module for a couple of reasons. I didn't want someone to point me where I had already been and also to highlight this module seems to be being actively developed independent of CPAN.

    Microsoft provides the SvrAny tool.

    Thanks. I will have to look into that.

    Regarding the link not pointing to the right place - I think that doesn't have anything to do with me or my post but thanks for pointing it out.

    Cheers - L~R

Re^2: Turn a perl script into a Win32 Service
by Limbic~Region (Chancellor) on Oct 13, 2008 at 00:08 UTC
    ikegami,
    I ended up going with the SrvAny tool. I wanted to share the following for those who might come across this post in the future.

    There doesn't seem to be a resource toolkit for Vista available for download. You can use the 2003 toolkit but you will get an error indicating "known compatibility issues". Additionally, you will get a cryptic "permission denied - contact your system administrator" even if you are logged in as an administrator. You will need to launch the command prompt with administrator rights. Finally, modifying the registry leaves quite a bit to be desired. If you need to have your service dependent on another service or some other "advanced" configuration - look at another service and use it as a starting point.

    Cheers - L~R

      All,
      It looks like SrvAny is a bust. The service starts and perl is in the process table, but it doesn't do anything. Even unbuffered output to STDERR in a BEGIN block doesn't show up until after stopping the service and then that's all it does. Still looking for solutions.

      Cheers - L~R

        Maybe you'll have better luck using wperl.exe instead of perl.exe.