Dlelete Folder and all Subfolders from User Profile VBS Script

On Error Resume Next
Set wshshell = wscript.CreateObject("wscript.shell")
Set wshsysenv = wshshell.environment("process")
Set fso = createobject("scripting.filesystemobject")
userprof = wshsysenv ("USERPROFILE")
fldname = userprof&"\Local Settings\Application Data\*"
Set fldr = fso.getfolder(fldname)
recurse fldr
sub recurse( byref fldr)
dim subfolders,files,folder,file
set subfolders = fldr.SubFolders
set files = fldr.files
for each file in files
file.Delete
next
For each folder in subfolders
recurse folder
Next
For Each subfolder In fldr.SubFolders
subfolder.Delete
Next
Set subfolders = nothing
set files = nothing
end sub

No comments:

Recent Posts