#X-CallInstall use strict; use warnings; use Win32; use Win32::Daemon; use Getopt::Long; my ($VERSION, %Config); $VERSION = "1.0"; %Config = (timeout_value => 2, log_file => join( "", Win32::GetFullPathName( $0 ) ), ); $Config{log_file} =~ s/[^.]*?$/log/; Getopt::Long::Configure( "prefix_pattern=(-|\/)" ); my $Result = GetOptions( \%Config, qw( install|i remove|r account_id|user=s account_password|pass=s help|?|h ) ); $Config{help} = 1 if( ! $Result || scalar @ARGV ); if( $Config{install}) { &Install(); exit(); } elsif ( $Config{remove}) { &Remove(); exit(); } elsif( $Config{help}) { &Syntax(); exit(); } #Configuration for Service sub GetServiceConfig { my $script_path = join("",Win32::GetFullPathName($0)); my %hash = ( name => 'Skeleton Socket Server', display => 'Skeleton Socket Server', description => "Skeleton Socket Server v$VERSION", path => $^X, user => $Config{account_id}, password => $Config{account_password}, parameters => "C:\\Pathtoscript\\skelserv.pl", ); return(\%hash); } #Install Service sub Install { my $svc_cfg = &GetServiceConfig(); if (Win32::Daemon::CreateService($svc_cfg)) { print "The $svc_cfg->{display} was Successfully installed.\n"; } else { print "Failed to Install $svc_cfg->{display} service.\nError: " . GetError() . "\n"; } } #Remove Service sub Remove { my $service_config = GetServiceConfig(); if( Win32::Daemon::DeleteService( $service_config->{name} ) ) { print "The $service_config->{display} was successfully removed.\n"; } else { print "Failed to remove the $service_config->{display} service.\nError: " . GetError() . "\n"; } } #Display if no Command Line Arguments Found! sub Syntax { print << "EOT"; A Win32 service that Create a Socket to listen on for X-Transport Messages. Syntax: [-l ] [-t