none
VBS代碼求助 RRS feed

  • 问题

  • 以下為一個vbs腳本代碼,執行為何不生效,也就達不到我釋放磁盤空間的目的.

    懇請各位指教問題出現在哪里.急.

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    dtmYesterday = Date - 90
    strYear = Year(dtmYesterday)
    strMonth = Month(dtmYesterday)
    If Len(strMonth) = 1 Then
    strMonth = "0" & strMonth
    End If
    strDay = Day(dtmYesterday)
    If Len(strDay) = 1 Then
    strDay = "0" & strDay
    End If
    strDate = strYear & strMonth & strDay &"000000.000000+000"
    wscript.echo(strDate)     //貌似只會執行到此,雙擊后會顯示三個月前的日期.
    Set colFiles = objWMIService.ExecQuery("SELECT * FROM CIM_DataFile WHERE Path = '\\MDaemon\\users\\gwspam.com\\bak\\7daysago.IMAP\\' AND Drive = 'd:' AND Extension = 'msg' AND CreationDate < '" & strDate & "'")
    For Each objFile In colFiles
    objFile.Delete()
    Next
    wscript.echo("success delete 100 DAYS ago mails!")
    2009年10月12日 3:40

答案