I'm guessing you want $status{'CurrentState'}. Try
poj#!perl use strict; use Win32::Service qw'GetServices GetStatus'; my @state_name = qw( '' Stopped START_PENDING STOP_PENDING Started CONTINUE_PENDING PAUSE_PENDING PAUSED ERROR ); my $hostname = 'localhost'; my %service=(); GetServices($hostname,\%service) or die "$!"; for my $name (sort keys %service){ my $shortname = $service{$name}; my %status = (); # keys to %status # CheckPoint # ControlsAccepted # CurrentState # ServiceSpecificExitCode # ServiceType # WaitHint # Win32ExitCode GetStatus($hostname, $shortname, \%status); my $state_no = $status{'CurrentState'}; printf " ServiceStatus: %s %s %s \n", $hostname, $shortname, $state_name[$state_no]; }
In reply to Re^3: how to print out windows service status
by poj
in thread how to print out windows service status
by ytjPerl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |