;**********************************************************************************************
;
; Function : DeleteFF($strPath, $strMethod, Optional $blnForce)
;
; Description : UDF for Cleaning Up Folders & Files
;
; Script Language : KiXtart
; Version : 4.02 or higher
;
; Script Dependecy : Microsoft Windows Scripting Host 5.6
; (see http://msdn.microsoft.com/scripting for download)
;
; Parameters : $strPath = full path name to folder or file.
; $strMethod = File to delete file.
; Folder to delete folder
; Content to delete folder content.
; $blnForce = optional, forces to delete, if read-only, hidden or system.
;
; Returns : 0 if succesful
;
; Examples : DeleteFF("fullpathname\filename", "File", "True")
; DeleteFF("fullpathname\foldername", "Folder", "True")
; DeleteFF("fullpathname", "Content", "False")
;
; Written by : Ryan Groeneveld
; Date : 13-07-2002
;
;**********************************************************************************************
Function DeleteFF($strPath, $strMethod, Optional $blnForce, Optional $logit)
$strFSO = "Scripting.FileSystemObject"
If KeyExist("HKCR\" + $strFSO) = 0
$Tmp = MessageBox("Object " + $strFSO + " is not installed !", "Error", 16)
Return
Else
$objFSO = CreateObject($strFSO)
If @Error <> 0
$Tmp = MessageBox("Object " + $strFSO + " can not be created !", "Error", 16)
Return
EndIf
EndIf
If Len($strPath) > 0
And Exist($strPath) = 1
if $logit = "1"
Log (" Deleting " + $strMethod + " " + $strPath,1)
endif
Select
Case $strMethod = "File"
$Tmp = $objFSO.DeleteFile($strPath, $blnForce)
$DeleteFF = @Error
Case $strMethod = "Folder"
$Tmp = $objFSO.DeleteFolder($strPath, $blnForce)
$DeleteFF = @Error
Case $strMethod = "Content"
$strContent = Dir($strPath)
While Len($strContent) > 0
And @Error = 0
If $strContent <> "."
And $strContent <> ".."
If GetFileAttr($strPath + "\" + $strContent) & 16
$Tmp = $objFSO.DeleteFolder($strPath + "\" + $strContent, $blnForce)
Else
$Tmp = $objFSO.DeleteFile($strPath + "\" + $strContent, $blnForce)
Endif
$DeleteFF = @Error
Endif
$strContent = Dir()
Loop
Case 1
Return
EndSelect
Else
if $logit = "1"
Log (" " + $strMethod + " " + $strPath + " doesn't exist.",1)
endif
Endif
EndFunction