Script to list non-Microsoft Services
Been lookin' for a way to lis开发者_如何转开发t 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
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:
- Obtain the
PathName
property of the current service (it holds the command line for the service). - Extract the service's file name from the
PathName
. - Obtain the
CIM_DataFile
class instance corresponding to the service file. - Check the file's
Manufacturer
property to find out whether or not the service is Microsoft's. For example, on my Vista box, theManufacturer
of all Microsoft services is Microsoft Corporation.
- Obtain the
Notes:
- Some magic may be required when parsing the
PathName
and querying theCIM_DataFile
class as thePathName
can include command-line arguments and may not include known file extensions (e.g. exe). - The
Manufacturer
property may beNull
for some non-Microsoft services.
精彩评论