As documented, the GetServices function returns a hashref populated with the
descriptive service names as keys and the short names as the values.  The
following code snippet displays the services sorted by short names.

use strict;
use Win32::Service;
#
my $server = '\\\\foo';
my (%services, %rservices);
Win32::Service::GetServices($server,\%services) or
    die "GetServices failed: $^E\n";
%rservices = reverse %services;
foreach my $service (sort {lc $a cmp lc $b} keys %rservices)
{
    print "$service ($rservices{$service})\n";
}
#

If you have the NT/2000 Resource Kit, then you can use the SC command line
utility:

    sc \\foo query bufsize= 5000

Gary


-----Original Message-----
From: Veeraraju_Mareddi [mailto:[EMAIL PROTECTED]]
Sent: Sunday, September 09, 2001 2:02 AM
To: 'Gary MacDonald'
Cc: '[EMAIL PROTECTED]'; '[EMAIL PROTECTED]'
Subject: RE: Win32::Service


Dear Gary

I Thank you very much for replying and sharing this

Where can I get the  short name list for All NT services including Exchange
services and User defined services. Is there any convert display name into
this short name..

With regards
Raju


        -----Original Message-----
        From:   Gary MacDonald [SMTP:[EMAIL PROTECTED]]
        Sent:   Sunday, September 09, 2001 10:52 AM
        To:     'Veeraraju_Mareddi'; [EMAIL PROTECTED]
        Cc:     [EMAIL PROTECTED]
        Subject:        RE: Win32::Service

        The server name should be preceded with \\.  However, in a Perl
string the backslashes must be doubled.  That is, "\\\\hotnt006".

        The service name should be the short name rather than the usually
longer descriptive name.  Counter-intuitively, for the service you are
querying, "Server" is the descriptive name and "LanmanServer" is the short
name.

        Below is the output from a Perl script that uses Win32::Service to
display the current status of every service installed on a WinNT 4.0
workstation.  The name to the right of the colon is the short name.  The
name in parentheses is the descriptive name.

        Stopped: Alerter (Alerter) 
        Running: AvSynMgr (AVSync Manager) 
        Running: Browser (Computer Browser) 
        Stopped: ClipSrv (ClipBook Server) 
        Stopped: DHCP (DHCP Client) 
        Running: EventLog (EventLog) 
        Stopped: EventSystem (COM+ Event System) 
        Running: LanmanServer (Server) 
        Running: LanmanWorkstation (Workstation) 
        Running: LmHosts (TCP/IP NetBIOS Helper) 
        Running: McShield (McShield) 
        Running: Messenger (Messenger) 
        Stopped: mnmsrvc (NetMeeting Remote Desktop Sharing) 
        Stopped: MSIServer (Windows Installer) 
        Stopped: NetDDE (Network DDE) 
        Stopped: NetDDEdsdm (Network DDE DSDM) 
        Running: Netlogon (Net Logon) 
        Stopped: nmagent (Network Monitor Agent) 
        Running: NtLmSsp (NT LM Security Support Provider) 
        Stopped: PerlSock (Perl Socket Service) 
        Running: PlugPlay (Plug and Play) 
        Running: ProtectedStorage (Protected Storage) 
        Running: RasAuto (Remote Access Autodial Manager) 
        Running: RasMan (Remote Access Connection Manager) 
        Stopped: RemoteAccess (Remote Access Server) 
        Stopped: Replicator (Directory Replicator) 
        Stopped: RPCLOCATOR (Remote Procedure Call (RPC) Locator) 
        Running: RpcSs (Remote Procedure Call (RPC) Service) 
        Running: Schedule (Task Scheduler) 
        Stopped: SENS (System Event Notification) 
        Running: Spooler (Spooler) 
        Running: TapiSrv (Telephony Service) 
        Stopped: UPS (UPS) 
        Running: WinMgmt (Windows Management Instrumentation) 

        Gary 

        -----Original Message----- 
        From: Veeraraju_Mareddi [ mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> ] 
        Sent: Saturday, September 08, 2001 4:18 AM 
        To: [EMAIL PROTECTED] 
        Cc: [EMAIL PROTECTED] 
        Subject: Win32::Service 


        Dear Team 

        I am trying to check a service on a remote machine using
Win32::Service. But 
        it is telling  "No such file or directorySuccess". 

        The script is given below Please look in to it.. 

        Service.pl 
        use Win32::Service; 

        if (Win32::Service::GetStatus("hotnt006", "Server", \%status) ==0) 
        { print "Failed :$!"; 
        } 
        print "Success"; 

        foreach $key( %status) 
        { 
        print "$key is $status{$key} \n"; 

        } 


        Thanx And Regards 
        Raju 
        _______________________________________________ 
        Perl-Win32-Admin mailing list 
        [EMAIL PROTECTED] 
        http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin
<http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin>  
        

Reply via email to