Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Command Line Service list

by OzzyOsbourne (Chaplain)
on Mar 07, 2002 at 20:08 UTC ( #150108=sourcecode: print w/ replies, xml ) Need Help??

Category: NT admin
Author/Contact Info OzzyOsbourne
Description: Gets services and their status on multiple servers from the command line.
#gets services on a bunch of servers, lists there name, and their stat
# Usage: server1 server2 server3 ...

use strict;
use Win32::Service qw(StartService StopService GetStatus GetServices);
my %statcodeHash = ('1' => 'stopped.','2' => 'start pending.','3' => '
+stop pending.','4' => 'running.','5' => 'continue pending.','6' => 'p
+ause pending.','7' => 'paused.');
my %serviceHash;
my ($service,%statusHash,$server);

foreach $server (@ARGV){
    print "\n\n##### $server #####\n\n";
    GetServices("$server",\%serviceHash) or next;
    foreach(sort keys %serviceHash){
        print "$_: $serviceHash{$_}\t";

sub getstatus{
    GetStatus("$_[0]", "$_[1]", \%statusHash);
    print "$statcodeHash{$statusHash{\"CurrentState\"}} \n";

Comment on Command Line Service list
Download Code

Back to Code Catacombs

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://150108]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2015-11-26 03:48 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (696 votes), past polls