in reply to Re^2: how to print out windows service status
in thread how to print out windows service status

it is not getting from Win32::Service::GetStatus('', $servicename, \%status); ?

There is nothing in the documentation to indicate that. Based on the test file this seems to be how to use the module (untested since I'm not on windows at the moment):

my %services; Win32::Service::GetServices("", \%services); while ( my ($k,$v) = each %services ) { print "$k\t$v\n"; my %status; Win32::Service::GetStatus("", $v, \%status); while ( my ($k,$v) = each %status ) { print "\t$k\t$v\n"; } }

Replies are listed 'Best First'.
Re^4: how to print out windows service status
by ytjPerl (Scribe) on Jul 31, 2017 at 15:11 UTC
    I checked hash %status, one of its key is 'CurrentState', so I am trying to do this
    Win32::Service::GetStatus($hostname, $servicename, \%status); print MYFILE " ServiceStatus: ", $hostname, $servicename, $status{Curr +entState}, "\n";
    , it is not working. I also tried to use this to map the number I defined for each status, it is still not working.
    if ($status{CurrentState} eq 4 ) {print MYFILE " ServiceStatus: ", $hostname, " ", $servicename, + " ", "is running\n";} else {print MYFILE " ServiceStatus: ", $hostname, " ", $service +name, " ", "is not running\n";}
    4 is map to 'Started' I have service is Started, but all my statements 'is not running'.