WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

User Sample Code

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

WMI query for Installed Codecs

 Keywords: Win32_CodecFile Installed Codecs WMI Query List Enumerate  

;Winbatch 2011B - simple WMI query for Installed Codecs
;Stan Littlefield, December 23, 2012
;
;NOTE: just threw in a quick UDF to convert the WMI dates to WB dates, ignoring the GMT offsey
;//////////////////////////////////////////////////////////////////////////////////////////////////
#DefineFunction cvtWMIDate(d)
d1=ItemExtract(1,d,".")
Return( StrSub(d1,1,4):":":StrSub(d1,5,2):":":StrSub(d1,7,2):":":StrSub(d1,9,2):":":StrSub(d1,11,2):":":StrSub(d1,13,2) )
#EndFunction

strComputer = "."
oWMI = GetObject("winmgmts:\\" : strComputer : "\root\cimv2")
oItems = oWMI.ExecQuery("Select * from Win32_CodecFile",,48)
cOut=""
cFile=DirScript():"Codecs.txt"
ForEach oItem In oItems
      cOut=cOut:"AccessMask:":oItem.AccessMask:@CRLF
      cOut=cOut:"Archive:":oItem.Archive:@CRLF
      cOut=cOut:"Caption:":oItem.Caption:@CRLF
      cOut=cOut:"Compressed:":oItem.Compressed:@CRLF
      cOut=cOut:"Compression Method:":oItem.CompressionMethod:@CRLF
      cOut=cOut:"Creation Class Name:":oItem.CreationClassName:@CRLF
      cOut=cOut:"Creation Date:":cvtWMIDate(oItem.CreationDate):@CRLF
      cOut=cOut:"CS Creation Class Name:":oItem.CSCreationClassName:@CRLF
      cOut=cOut:"CS Name:":oItem.CSName:@CRLF
      cOut=cOut:"Description:":oItem.Description:@CRLF
      cOut=cOut:"Drive:":oItem.Drive:@CRLF
      cOut=cOut:"8.3 File Name:":oItem.EightDotThreeFileName:@CRLF
      cOut=cOut:"Encrypted:":oItem.Encrypted:@CRLF
      cOut=cOut:"Encryption Method:":oItem.EncryptionMethod:@CRLF
      cOut=cOut:"Extension:":oItem.Extension:@CRLF
      cOut=cOut:"File Name:":oItem.FileName:@CRLF
      cOut=cOut:"File Size:":oItem.FileSize:@CRLF
      cOut=cOut:"File Type:":oItem.FileType:@CRLF
      cOut=cOut:"FS Creation Class Name:":oItem.FSCreationClassName:@CRLF
      cOut=cOut:"FS Name:":oItem.FSName:@CRLF
      cOut=cOut:"Group:":oItem.Group:@CRLF
      cOut=cOut:"Hidden:":oItem.Hidden:@CRLF
      cOut=cOut:"Installation Date:":cvtWMIDate(oItem.InstallDate):@CRLF
      cOut=cOut:"In Use Count:":oItem.InUseCount:@CRLF
      cOut=cOut:"Last Accessed:":cvtWMIDate(oItem.LastAccessed):@CRLF
      cOut=cOut:"Last Modified:":cvtWMIDate(oItem.LastModified):@CRLF
      cOut=cOut:"Manufacturer:":oItem.Manufacturer:@CRLF
      cOut=cOut:"Name:":oItem.Name:@CRLF
      cOut=cOut:"Path:":oItem.Path:@CRLF
      cOut=cOut:"Readable:":oItem.Readable:@CRLF
      cOut=cOut:"Status:":oItem.Status:@CRLF
      cOut=cOut:"System:":oItem.System:@CRLF
      cOut=cOut:"Version:":oItem.Version:@CRLF
      cOut=cOut:"Writeable:":oItem.Writeable:@CRLF
      cOut=cOut:@CRLF:@CRLF
Next
FilePut(cFile,cOut)
Run("notepad.exe", cFile)
oItem=0
oItems=0
oWMI=0
Exit

Article ID:   W18487
Filename:   Query for Installed Codecs.txt
File Created: 2012:12:24:09:48:02
Last Updated: 2012:12:24:09:48:02