Subject: Re: Listing services
From: David Rothenberger <[email-masked]>
To: Colin JN Breame <[email-masked]>
Cc: [email-masked]
Date: Fri, 04 Mar 2005 09:30:03 -0800

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? -> [email-masked]
GPG/PGP: 0x7F67E734, C233 365A 25EF 2C5F C8E1 43DF B44F BA26 7F67 E734

   This page intentionally left blank.
#!/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