adam2005 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm running perl on win32 (activestate perl). I want to be able to query/stop/start services on a Win2000 box.

I did a search on CPAN and had a look at Win32::Service which would be ideal however when I try to retrieve via PPM it appears as there are no available packages.

Any other way that I can achieve this?

Thanks,
Adam

  • Comment on How to query/stop/start Windows services?

Replies are listed 'Best First'.
Re: How to query/stop/start Windows services?
by renodino (Curate) on Dec 16, 2005 at 04:03 UTC
    Maybe the easiest is to just hack up a system() call to run the appropriate "sc" command ?

    That being said, I just successfully installed Win32::Service via PPM... what version of AS Perl were you running ? (Mine is 5.8.6). Do you have ActiveState setup as a repository ?

      I have version 5.6.1 of AS Perl and the repository it's set to is 'ActiveState PPM2 Repository' and also 'ActiveState package Repository'. Dooes upgrading my perl version to 5.8.6 make a difference??
        Dooes upgrading my perl version to 5.8.6 make a difference??

        Sorry, I wouldn't know. Shortly after I upgraded to 5.8, I dumped 5.6 and never looked back. If you're stuck w/ 5.6, you'll likely need to either get a VC++ environment and build from scratch from CPAN sources, or try the other suggestion (i.e., system("sc stop $service"); ). You might check AS's PPM page for instructions on accessing older version repositories.

        However, if you have the option, I'd highly recommend upgrading to 5.8.6+. 5.6 is getting a bit long in the tooth at this point, and you'll find an increasing number of modules now require 5.8, in part because it provides so many feature enhancements.

Re: How to query/stop/start Windows services?
by secret (Beadle) on Dec 16, 2005 at 08:45 UTC

    I don't understand : Win32::Service is available by default in my standard ActiveState distribution. You don't to install it . Have you tried to use it, it should be there. If not there's something broken in your installation, and you could always re-install .

      I just upgraded to the latest version of AS Perl (5.8.7) and I can now use Win32::Service with no problems.....but now I don't understand *why* it works.

      If I use PPM3 and query all installed modules:

      query *

      ....there is no mention of the 'Win32-Service' module at all, the only Win32 module is 'Win32-OLE'.

      Shouldn't 'Win32-Service' show as an installed module?

        Some modules of the Win32 namespace need to be installed via the CPAN. Some other are in the core activestate distribution (although they are not part of the Perl source ) and I assume that is why they do not show as "installed" modules with ppm :

          The builtin functions are marked as [CORE] and the other ones as [EXT] in the following alphabetical listing. The Win32 module is not part of the Perl source distribution; it is distributed in the libwin32 bundle of Win32::* modules on CPAN. The module is already preinstalled in binary distributions like ActivePerl.