Announcement

Collapse
No announcement yet.

WMI Query help!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    WMI Query help!

    Any of you API wonks also know more about WMI Queries than you care to admin? Cause I am floundering a bit and would love to get a code check.
    I am trying to filter all files on the user desktop newer than a particular datetime. The code works if I don't include the bit about time, so I assume I have a problem in my formatting, but I can't for the life of me find it.
    FWIW, the time I am filtering on is noon yesterday, and Scriptomatic tells me that CreationDate is a valid parameter given the WMI Class & ResultClass.

    I could punt I guess, and search a larger collection for the CreationDate but filtering via WMI seems the more elegant solution.

    Thanks!!!
    Gordon

    Code:
    strWMIScriptStart = "20120707120000.000000-000"
    
    
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    
    
    Set objRegistry=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
     
    strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
    strValueName = "Desktop"
    objRegistry.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strUser
    
    
    Set colFileList = objWMIService.ExecQuery _
        ("ASSOCIATORS OF {Win32_Directory.Name='" & strUser & "'} Where " _
            & "ResultClass = CIM_DataFile And CreationDate > '" & strWMIScriptStart & "'")
    Pragmatic Praxis

Related Topics

Collapse

Working...
X