views:

89

answers:

1

Hi guys Been lookin' for a way to list the non-Microsoft Services to a *.txt file.

Either using vbs or a batch file will be sufficient.

I've tried numerous ways with WMI and the sc.exe command, but can't seem to put my finger on it.

Thanks,

Tim

+2  A: 

The Win32_Service WMI class doesn't have a property that would return the service's manufacturer, but the CIM_DataFile class does. So I can suggest the following solution:

  • Query and enumerate the Win32_Service class instances.
  • In the loop:
    1. Obtain the PathName property of the current service (it holds the command line for the service).
    2. Extract the service's file name from the PathName.
    3. Obtain the CIM_DataFile class instance corresponding to the service file.
    4. Check the file's Manufacturer property to find out whether or not the service is Microsoft's. For example, on my Vista box, the Manufacturer of all Microsoft services is Microsoft Corporation.

Notes:

  • Some magic may be required when parsing the PathName and querying the CIM_DataFile class as the PathName can include command-line arguments and may not include known file extensions (e.g. exe).
  • The Manufacturer property may be Null for some non-Microsoft services.
Helen