1st June 16:13
"Martin" <firstname.lastname@example.org> skrev i melding
****** Script begins here ********
A similar thing happends to me. don't know why, but it seems that under
certain cir***stances the script just stops running. In my example, my
script was trying to delete some files, and create a logg for those files
(if any) that failed to be deleted. Well, instead of waste my time
explaining the script problem, i rather just paste it into here:
' Delete all files in folder "TestFolder"
' While it deletes Files in the folder, it Write to a log-file
' the date and time. After that, the log-file get some more lines at the end
' listing up files that was successfully deleted, and those one
' that couldn't be deleted.
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
Set Test_FolderObj = FileSystemObject.getFolder("G:\TestFolder")
Set ParentFolderToThisFile =
Set FilesCollectionToBeDeleted = Test_FolderObj.files
' Create a text-stream file, the log-file.
Set logg = FileSystemObject.OpenTextFile(ParentFolderToThisFi le.path &
"\Logfile.log", 8, True)
' cal the sub-procedure
On Error Resume Next
If FilesCollectionToBeDeleted.count > 0 Then ' Antall filer > 0.
logg.writeLine Date & VbTab & Time & VbTab & "Number of sucessed file
deletes: " & FilesCollectionToBeDeleted.count
logg.writeLine Date & VbTab & Time & VbTab & "No files to delete"
For each EachFileToDelete in FilesCollectionToBeDeleted
MsgBox "Test: Te code runs so far"
' Error. That message never comes up.
If err.number <> 0 Then ' File couldn't be deleted for some reason.
'MsgBox "Was not alowed to delete te file named " & EachFileToDelete.name
logg.writeLine " The following file wasn't deleted: " &
'MsgBox "File deleted " & EachFileToDelete.name
logg.writeLine " -- " & EachFileToDelete.name
***** End script ********
Of couse, my announcement of my own problem will probably not help you, but
now we have a common type of problem. It has to be an error in windows
scripting host, if i'm not blinded to see my own errors, but i couldn't find
anyone. Hope there is a solution.