- Joined
- Jul 11, 2007
- Messages
- 1
- Reaction score
- 0
I am looking for some help to fix a error messae that my VB Script is generating.
I need to remove files from a windows 2003 server that are older than 7 years with the modified date. I can run this on my local system (WinXP) but when I run on a 2003 server I get the error (null): The remote procedure call failed. The line number for the error is (26,1). This is the line For Each objFile in colFiles. I did a normal Windows search and found over 98000 files that meet this condition. Do I have a max size issue or memory issue?
' AUTHOR: HCC Life , HCC Life
' DATE : 7/10/2007
' COMMENT:
'==========================================================================
Dim WshShell
Dim Fso
Dim ForReading
Dim ForWriting
Dim ForAppending
Dim LogFile
ForReading = 1
ForWriting = 2
ForAppending = 8
Set Fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
sPrograms = WshShell.SpecialFolders("AllUsersPrograms")
path=FSO.getabsolutepathname("")
'Script to find files that have not been modified in 7 years.
strDate = "20000710000000.000000+000"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery ("Select * From CIM_DataFile Where LastModified < '" & strDate & "'")
Set LogFile = fso.OpenTextFile("c:\archiveproject\result.log", ForWriting, True)
i=0
For Each objFile in colFiles
LogFile.Write objFile.Name &";"&objfile.lastmodified&";"&objfile.filesize&VbCrLf
i=i+1
WScript.Echo "File #"&i
'Wscript.Echo objFile.Name
Next
LogFile.Close
I need to remove files from a windows 2003 server that are older than 7 years with the modified date. I can run this on my local system (WinXP) but when I run on a 2003 server I get the error (null): The remote procedure call failed. The line number for the error is (26,1). This is the line For Each objFile in colFiles. I did a normal Windows search and found over 98000 files that meet this condition. Do I have a max size issue or memory issue?
' AUTHOR: HCC Life , HCC Life
' DATE : 7/10/2007
' COMMENT:
'==========================================================================
Dim WshShell
Dim Fso
Dim ForReading
Dim ForWriting
Dim ForAppending
Dim LogFile
ForReading = 1
ForWriting = 2
ForAppending = 8
Set Fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
sPrograms = WshShell.SpecialFolders("AllUsersPrograms")
path=FSO.getabsolutepathname("")
'Script to find files that have not been modified in 7 years.
strDate = "20000710000000.000000+000"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery ("Select * From CIM_DataFile Where LastModified < '" & strDate & "'")
Set LogFile = fso.OpenTextFile("c:\archiveproject\result.log", ForWriting, True)
i=0
For Each objFile in colFiles
LogFile.Write objFile.Name &";"&objfile.lastmodified&";"&objfile.filesize&VbCrLf
i=i+1
WScript.Echo "File #"&i
'Wscript.Echo objFile.Name
Next
LogFile.Close