I'm sorry to bring this back up.In node 746998 , I brought about an example of a script using pdk7.3's deployment tootls perlsvc.Here is the jist of that code.
##################################################################### # # Example code for PerlSvc using Win32::GuiConsole # ##################################################################### #!Perl -w #-------------------------------------------------------------------- # Package Initialise #-------------------------------------------------------------------- package PerlSvc; use strict; use vars qw($CONSOLEDEBUG); #use Win32::GuiConsole 0.02; use Getopt::Long; #-------------------------------------------------------------------- # Console Init #-------------------------------------------------------------------- # ... some code to initialise buffers if we are in console debug mode +? $CONSOLEDEBUG = 1; #if($CONSOLEDEBUG) { Win32::GuiConsole::open_console('Perl Service Des +ktop Debugging Console'); } #-------------------------------------------------------- # The Config provides defaults for the service parameters # These can be overidden in the 'Install' procedure via # the --install command line option # All available options included for reference #-------------------------------------------------------- our %Config = (ServiceName => 'servicetest', DisplayName => 'A Test Service', StartType => 'auto', # auto, manual Interactive => 1, # boolean Description => 'Service with added console', UserName => undef, # will run as local system accou +nt Password => undef, StartNow => 1, # if set to false, service would + not run on install Dependencies => '', # ref to array of strings naming +service dependencies Parameters => '', # command line params passed to +exec on service start ); #-------------------------------------------------------- # setup when we're not running as service #-------------------------------------------------------- unless (defined &ContinueRun) { # we're not running as a service so use some defaults # and call the Interactive setup *ContinueRun = sub { sleep 1; return 1; }; *RunningAsService = sub { return 0 }; my $discard = RunningAsService(); Interactive(); } sub Interactive { # called when not started as a service Install(); Startup(); } #-------------------------------------------------------------- # service calls - Install, # Remove, # Help, # Pause, # Continue, # Startup #-------------------------------------------------------------- #-------------------------------------------------------------- # service Install #-------------------------------------------------------------- sub Install { my $help; Getopt::Long::GetOptions( 'service=s' => \$Config{ServiceName}, 'display=s' => \$Config{DisplayName}, 'starttype=s' => \$Config{StartType}, 'interactive=s' => \$Config{Interactive}, 'description=s' => \$Config{Description}, 'username=s' => \$Config{UserName}, 'password=s' => \$Config{Password}, 'startnow=s' => \$Config{StartNow}, 'dependencies=s' => \$Config{Dependencies}, 'parameters=s' => \$Config{Parameters}, 'help' => \$help, ); if($help) { &Help; } } #-------------------------------------------------------------- # service Remove #-------------------------------------------------------------- sub Remove { } #-------------------------------------------------------------- # service Help ---- accessible via command line #-------------------------------------------------------------- sub Help { # called when started with --help my $help = "Options when installing as service:\n\n"; $help .= '--install install as service' . "\n"; $help .= '--remove remove service' . "\n"; $help .= '--service the short service name' . "\n"; $help .= '--display the long service name' . "\n"; $help .= '--starttype auto | manual (default auto)' . "\n"; $help .= '--interactive 0 | 1 (allow interaction with desktop) ( +default 0 = false)' . "\n"; $help .= '--description a description of the service' . "\n"; $help .= '--username DOMAIN\USERNAME or .\USERNAME for local +user' . "\n"; $help .= '--password user password' . "\n"; $help .= '--startnow start service now' . "\n"; $help .= '--dependencies a list of services on which this depends +' . "\n"; $help .= '--parameters parameters to pass when service starts' +. "\n"; print $help; exit(0); } #-------------------------------------------------------------- # service Pause #-------------------------------------------------------------- sub Pause { print "I'm Pausing\n"; } #-------------------------------------------------------------- # service Continue #-------------------------------------------------------------- sub Continue { print "I'm resuming after a pause\n"; } #-------------------------------------------------------------- # service Startup #-------------------------------------------------------------- sub Startup { #----------------------------------------------------------------- +------- # service 'continue' loop #----------------------------------------------------------------- +------- while (ContinueRun(1)) { print "I'm a service and I'm running\n"; # do prog .......... print STDERR "And I also output errors\n"; } #----------------------------------------------------------------- +------- # clean up code for stopping service #----------------------------------------------------------------- +------- print "Thank you and goodnight\n"; } 1;
The script gets installed as a service only under c:.The problem is that though the script gets installed, it doesn't perform any action.It should move files from one directory in the d: to another in the d:.I am wondering if this is a permissions issue( i'm running as local user).

The second issue is that when i try and remove it using myservice.exe --remove it keeps trying to stop the service but is not successful.hence the service doesn't get removed from the windows services unless i reboot.

Could anyone help me rectify this?Is there anything wrong or missing from the remove block?Thanks

Sandhya

In reply to perl svc and win 32 services, installed but not working by smanicka

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.