Hello, I came across this example script for perlsvc offered as a part of pdk deployment tools.Since i havebeen trying to use that, i went ahead and created a .exe file for that code.I would like to know how i can go ahead with installing this as a service since it works if i say c:\> test.exe but if i say c:\> install test.exe ,it pops out as unknown command.net start also doesn't seem to work.would anyone be able to tell me how to perform the installations?

The code and the exe file are here http://www.esnips.com/web/perlstuff/ and the code is:

##################################################################### # # 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;
UPDATE I did get to install the service using test.exe --install . the output is "test service installed successfully.Test Service failed to start :The system cannot findthe path specified".I'm not sure if this is because of office security which doen't allow us access to the c:\> but the command prompt always points to a h:/>.Any suggestions would be welcome Thanks. -Sandhya

In reply to perl svc, installation of the service 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.