Following VBScript can be used to delete files/folders from Each and every User profile
Dim FSfolder
Dim subfolder
Dim i
set objshell = CreateObject("Wscript.shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
Profile = strSysDrive & "C:\Documents and Settings"
Set FSfolder = FSO.GetFolder(Profile) 'getting the user profile folders
For Each subfolder In FSfolder.SubFolders
If (subfolder.Name <> "All Users" And subfolder.Name <> "Default User"_
and subfolder.Name <> "LocalService" and subfolder.Name <> "NetworkService") Then
folder1=Profile & "\" & subfolder.Name & "\Application Data\Sample"
DeleteThisFolder(folder1)
end if
Next
'*******************************************************************************************************
Function DeleteThisFolder(FolderName)
If FSO.FolderExists(FolderName) Then
objshell.Run "CMD.EXE /C RD /S /Q """ & FolderName & """",0,True
End If
End Function
What if profile is not under "C:\Document and Settings" because in many organization user profile folder is on another drive or on server.
ReplyDeleteThis method fails in above senario.