开发者

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:
    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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜