Lists services(daemon) on a given system : Service « Win32 « Perl






Lists services(daemon) on a given system

  

#!/usr/bin/perl -w

use Win32::Service;


$host = '';
$status = Win32::Service::GetServices($host, \%services);

if ($status) {
   print_hash( \%services );
} else {
   print_error();
}


sub print_hash {
   my($hash_ref) = $_[0];
   @keys = keys( %$hash_ref );
   @sorted = sort( @keys );
   foreach $key (@sorted) {
      print "$key $$hash_ref{$key}\n";
   }
}

sub print_error {
    print Win32::FormatMessage( Win32::GetLastError() );
}

   
    
  








Related examples in the same category

1.Starting services
2.Stopping services