回复2楼:
vbs调用WMI获取文件制造商- Dim FilePath,WMIPathMode
- FilePath=InputBox("请输入文件全路径(例如以下路径格式)","文件路径","C:\windows\system32\user32.dll")
- If FilePath <> "" Then
- WMIPathMode=Replace(FilePath,"\","\\")
- Set OBJWMI = GetObject("winmgmts:\\.\root\CIMV2")
- Set colManufacturer = OBJWMI.ExecQuery("SELECT * FROM CIM_DataFile Where Name='" & WMIPathMode & "'")
- For Each OBJManufacturer In colManufacturer
- If Trim(OBJManufacturer.Manufacturer) <> "" Then
- MsgBox "文件全路径是: "&LCase(Trim(OBJManufacturer.Name))&chr(10)&"文件制造商是: "&Trim(OBJManufacturer.Manufacturer)
- Else
- MsgBox "文件全路径是: "&LCase(Trim(OBJManufacturer.Name))&chr(10)&"文件制造商是:空"
- End If
- Next
- End If
复制代码 直接用wmic:- wmic datafile where name="c:\\windows\\system32\\notepad.exe" get Manufacturer
复制代码 你想获取服务的制造商~~可以参考参考这个
关于服务的:
批处理结合VBS获取服务基本状态:
本来可以直接用VBS搞定的,最近搞VBS比较频繁,就用用批处理吧..结合一下练练手..- @echo off
- cls
- echo set OBJWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")>ServiceStatus.vbs
- echo set colInstalledServices = OBJWMIService.ExecQuery("Select * From Win32_Service")>>ServiceStatus.vbs
- echo For Each OBJService in colInstalledServices>>ServiceStatus.vbs
- echo Wscript.Echo OBJService.State ^& vbTab ^& OBJService.DisplayName>>ServiceStatus.vbs
- echo Next>>ServiceStatus.vbs
- cscript //nologo ServiceStatus.vbs >ServiceStatus.txt
- for /f "skip=1 tokens=2 delims=:" %%i in ('find /v /c "" ServiceStatus.txt') do set total=%%i
- for /f "skip=1 tokens=2 delims=:" %%a in ('find /i /c "running" ServiceStatus.txt') do set rcount=%%a
- for /f "skip=1 tokens=2 delims=:" %%x in ('find /i /c "Stopped" ServiceStatus.txt') do set scount=%%x
- ping -n 2 127.1 >nul 2>nul
- echo 计算机系统里安装的服务总共有%total% 个。
- echo.
- ping -n 3 127.1 >nul 2>nul
- echo 正在运行的服务有%rcount% 个。列表如下:
- echo.
- ping -n 3 127.1 >nul 2>nul
- for /f "skip=2 delims=" %%k in ('find /i "running" ServiceStatus.txt') do echo %%k
- ping -n 3 127.1 >nul 2>nul
- echo.
- echo 已经停止的服务有%scount% 个。列表如下:
- echo.
- ping -n 3 127.1 >nul 2>nul
- for /f "skip=2 delims=" %%p in ('find /i "stopped" ServiceStatus.txt') do echo %%p
- echo.
- ping -n 3 127.1 >nul 2>nul
-
- echo set OBJWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")>stoppable.vbs
- echo set colServices = objWMIService.ExecQuery("Select * From Win32_Service Where AcceptStop = True")>>stoppable.vbs
- echo For Each OBJService in colServices>>stoppable.vbs
- echo Wscript.Echo OBJService.State ^& vbTab ^& OBJService.DisplayName>>stoppable.vbs
- echo Next>>stoppable.vbs
-
- cscript //nologo stoppable.vbs >stoppable.txt
-
- for /f "skip=1 tokens=2 delims=:" %%e in ('find /i /c "running" stoppable.txt') do set srcount=%%e
- echo 可以停止但是正在运行的服务有%srcount% 个。列表如下:
- echo.
- ping -n 3 127.1 >nul 2>nul
- for /f "skip=2 delims=" %%g in ('find /i "running" stoppable.txt') do echo %%g
- ping -n 3 127.1 >nul 2>nul
- echo.
- for /f "skip=1 tokens=2 delims=:" %%j in ('find /i /c "stopped" stoppable.txt') do set sscount=%%j
- if not "%sscount%"==" 0" (
- echo 可以停止而且已经停止的服务有%sscount% 个。列表如下:
- echo.
- ping -n 3 127.1 >nul 2>nul
- for /f "skip=2 delims=" %%c in ('find /i "stopped" stoppable.txt') do echo %%c
- ) else echo 可以停止而且已经停止的服务有 0 个。
- del ServiceStatus.vbs stoppable.vbs ServiceStatus.txt stoppable.txt >nul
- pause
复制代码 关于服务的分类,可以参考这帖子:能分出system auto 等```
http://bbs.bathome.net/viewthread.php?tid=338 |