wmi 取得選定檔案更新的日期

jidongzheng發表於2009-08-10

這是microsoft提供的全部wmi物件介面,不明確的時候,可以在這個地方查詢

我們就回到具體問題,寫程式碼並不難,難的是一些類物件的確屬性經常被搞錯.

原來一直在類CIM_DataFile 中查詢檔案的屬性名,都沒有成功,

結果,在interface : IItem Interface 中找到相應的屬性名

=============================================

以下是一段示例程式碼

[@more@]

strComputer = "192.168.15.238"
strUser = "XXXXXXXXX" ' 系統使用者名稱
strPasswd = "XXXXXXXX" '系統登入口令

'Set wbemServices = GetObject("winmgmts:" & strComputer)
'Set wbemObjectSet = wbemServices.InstancesOf("Win32_NTLogEvent","administrator","cmmscmms")

Set wbemServices = CreateObject("WbemScripting.SWbemLocator")
Set wbemConnects = wbemServices.ConnectServer(strComputer,"root/CIMV2",strUser,strPasswd)
'Set wbemObjectSet = wbemConnects.ExecQuery("Select * from Win32_LogicalMemoryConfiguration")

'Set wbemObjectSet = wbemConnects.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='c:'} Where ResultClass = CIM_DataFile")
Set wbemObjectSet = wbemConnects.ExecQuery ("Select * from CIM_DataFile where Name = 'c:test.log'")

For Each ccc In wbemObjectSet
WScript.Echo "Total Physical Memory : " & ccc.LastModified
'CreationDate
'CreationDate
'
'
'

Next

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/197458/viewspace-1025099/,如需轉載,請註明出處,否則將追究法律責任。

相關文章