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_Serviceclass instances. - In the loop:
- Obtain the
PathNameproperty of the current service (it holds the command line for the service). - Extract the service's file name from the
PathName. - Obtain the
CIM_DataFileclass instance corresponding to the service file. - Check the file's
Manufacturerproperty to find out whether or not the service is Microsoft's. For example, on my Vista box, theManufacturerof all Microsoft services is Microsoft Corporation.
- Obtain the
Notes:
- Some magic may be required when parsing the
PathNameand querying theCIM_DataFileclass as thePathNamecan include command-line arguments and may not include known file extensions (e.g. exe). - The
Manufacturerproperty may beNullfor some non-Microsoft services.
加载中,请稍侯......
精彩评论