Windows Perl Scripting Forums » Perl

Updating Service Entry

(2 posts)

Tags:


  1. dsully
    Member

    I'd like to be able to toggle a service's start_type from AUTO to DEMAND.

    It doesn't look like Win32::Daemon can do that, except with a DeleteService() followed by a CreateService() which I'd like to avoid.

    I've been told that there are Win32::Service extensions that might help

    Thanks
    Posted 8 years ago #
  2. Dave
    Perl guy

    You can either use Win32::Lanman's ChangeServiceConfig() method or Win32::Daemon's ConfigureService() method. The latter is discussed in chapter 8 of my second book "Win32 Perl Scripting: The Administrator's Handbook" (http://www.roth.net/books/handbook/). Example 8.5 from the book briefly demonstrates how to modify a service's configuration. In your case, however, you would want to change the name of the service in the %ServiceConfig hash, remove the credentials and add the 'start_type' field:

    %ServiceConfig = (
        name       =>  'YourServiceName',
        machine    =>  "\\\\" . Win32::NodeName(), # Represent the local machine
        start_type =>  SERVICE_AUTO_START,
    );



    Note that you could use a start_type of:
    -SERVICE_AUTO_START
    -SERVICE_DEMAND_START
    -SERVICE_DISABLED

    I'll ensure that our web page on this (http://www.roth.net/perl/daemon/) is updated to reflect this.
    Posted 8 years ago #

RSS feed for this topic

Reply

You must log in to post.