delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/03/04/12:30:32

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Fri, 04 Mar 2005 09:30:03 -0800
From: David Rothenberger <daveroth AT acm DOT org>
Subject: Re: Listing services
In-reply-to: <200503041150.14903.colin@breame.net>
To: Colin JN Breame <colin AT breame DOT net>
Cc: cygwin AT cygwin DOT com
Message-id: <42289B1B.7000103@acm.org>
MIME-version: 1.0
References: <200503041150 DOT 14903 DOT colin AT breame DOT net>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com

--------------enig2929BCFB48771279919415A2
Content-Type: multipart/mixed;
 boundary="------------040809060905050200080901"

This is a multi-part message in MIME format.
--------------040809060905050200080901
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

On 3/4/2005 3:50 AM, Colin JN Breame wrote:
> Hello,
>
> Anyone know how to list the names and descriptions of all the services on the
> system?
>
> Cheers,

I do it with the following script which uses /proc.

--
David Rothenberger                spammer? -> spam AT daveroth DOT dyndns DOT org
GPG/PGP: 0x7F67E734, C233 365A 25EF 2C5F C8E1 43DF B44F BA26 7F67 E734

   This page intentionally left blank.

--------------040809060905050200080901
Content-Type: text/plain;
 name="lsservices"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="lsservices"

#!/bin/sh
usage() {
  cat <<EOF
usage: `basename $0` [-n] [--]
  -n: Display names
EOF
}

displayNames() { false; }
while getopts :n OPT; do
  case $OPT in
    n|+n)
      displayNames() { true; }
      ;;
    *)
      usage
      exit 2
  esac
done
shift `expr $OPTIND - 1`

if displayNames; then
  cd /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services
  for s in `ls -1 | sort -f`; do
    displayName=""
    if [ -f $s/DisplayName ]; then
      displayName=`cat /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/$s/DisplayName`
    fi
    echo "$s" | awk '{printf("%-30s: ", $1)}'
    echo $displayName
  done
else
  ls -1 /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services | sort -f
fi

--------------040809060905050200080901--

--------------enig2929BCFB48771279919415A2
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCKJshtE+6Jn9n5zQRAnt0AKD3JcDwmQ22Q4NlQ30+mLeoGFxt5QCcCMsf
NNWx0Yt/hc9AHdO9/p6eMG0=
=TtAp
-----END PGP SIGNATURE-----

--------------enig2929BCFB48771279919415A2--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019