This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Listing services


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@daveroth.dyndns.org
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

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]