I do not think you need to remove the DOS box. This is not the issue. You use your script to install the service, I understand. You start the service within the win32 SERVICES dialog. I think.

Problem is, that your script actually has neither a start hook nor a run hook!

Initialize the daemon with something like

Win32::Daemon::RegisterCallbacks( { start => \&startService, stop => \&stopService, pause => \&pauseService, continue => \&continueService, running => \&runService, } );

Next, define some callbacks.

sub startService { # start the win32 service daemon # ------------------------------ my ($event, $context) = @_; $context -> { last_state } = SERVICE_RUNNING; Win32::Daemon::State( SERVICE_START_PENDING, 30000 ); # do what need to be done # exit Win32::Daemon::State( SERVICE_RUNNING ); } # ==================================================================== +========== sub stopService { # stop the win32 service daemon # ----------------------------- my ($event, $context) = @_; $context -> { last_state } = SERVICE_STOPPED; Win32::Daemon::State( SERVICE_STOP_PENDING, 30000 ); # do what needs to be done # exit Win32::Daemon::State( SERVICE_STOPPED ); Win32::Daemon::StopService(); } # ==================================================================== +========== sub pauseService { # let the win32 service daemon make a pause # ----------------------------------------- my ($event, $context) = @_; $context -> { last_state } = SERVICE_PAUSED; # do what needs to be done # exit Win32::Daemon::State( SERVICE_PAUSED ); } # ==================================================================== +========== sub continueService { # let the win32 service daemon exit a pause # ----------------------------------------- my ($event, $context) = @_; $context -> { last_state } = SERVICE_RUNNING; # do what needs to be done # exit Win32::Daemon::State( SERVICE_RUNNING ); } # ==================================================================== +========== sub runService { # this is the callback of by the win32 service daemon # --------------------------------------------------- my ($event, $context) = @_; if ( Win32::Daemon::State() == SERVICE_RUNNING ) { # count the number of calls (I do not know why) $context -> { count }++; } }

Regarding your error message I add the following comment. Your service did not respond to the start method, because there is none. If there is a start method, you need to be careful to inform the win32 service manager, how long your startup will take. See this Win32::Daemon::State( SERVICE_STOP_PENDING, 30000 ); statement.


In reply to Re: Perl script as windows service by m-rau
in thread Perl script as windows service by rockets12345

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.