柠檬墨绿色 发表于 2016/11/8 15:15

VBS实现查询服务的制造商

  select * from win32_service 这个能查服务名称、状态……

  但我想查这个服务的制造商,如微软、农业银行,还是未知的??这个属性是什么,谢谢……

  我发现msconfig中可以看见的,但无法提取

  下面给出解答,一种间接方法:

  根据服务名获取到关联的主程序,再从主程序获取制造商

  ?

  1

  2

  3

  4

  5

  6

  7

  8

  9

  10

  11

  12

  13

  14

  15

  16

  17

  18

  19

  20

  21

  22

  23

  24

  25

  26

  27

  28

  29

  30

  31

  32

  33

  Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

  Set Services = objWMIService.ExecQuery("Select * from Win32_Service")

  Set fso = CreateObject("Scripting.FileSystemObject")

  Set objShell = CreateObject("Shell.Application")

  Set objFolder = objShell.NameSpace(0)

  i = 0

  Do

  If objFolder.GetDetailsOf("", i) = "公司" Then '非中文系统自行修改

  Exit Do

  Else

  i = i+1

  End If

  Loop

  For Each objService in Services

  path = GetPath(objService.PathName)

  IF fso.GetExtensionName(path) = "" Then path = path & ".exe"

  Set objFolder = objShell.NameSpace(fso.GetParentFolderName(path))

  Set objItem = objFolder.ParseName(fso.GetFileName(path))

  comp = objFolder.GetDetailsOf(objItem, i)

  If comp = "" Then comp = "未知"

  info = info & "服务:"& objService.DisplayName &" 制造商:"& comp & vbCrLF

  Next

  fso.CreateTextFile("info.txt", true)。WriteLine info

  MsgBox "完成"

  Function GetPath(strng)

  Dim re

  Set re = New RegExp

  re.Pattern = "^""?(。+\\[^\\\s""]+)。*"

  GetPath = re.Replace(strng,"$1")

  Set regEx = Nothing

  End Functionwww.9ask.cn/zhuzhou/
页: [1]
查看完整版本: VBS实现查询服务的制造商