Advertisement
gn4711

Clean this directory

Feb 29th, 2012
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. On Error Resume Next
  2.  
  3. Const vbYes = 6
  4. Const vbYesNoQuestion = 36
  5.  
  6. Set fso = CreateObject("scripting.filesystemobject")
  7. set wshShell = CreateObject("WScript.Shell")
  8.  
  9. s = fso.getfolder(WshShell.ExpandEnvironmentStrings("%temp%")).shortpath
  10. If UCase(s) = UCase(fso.GetFolder(".").ShortPath) Then
  11.     bRet = True
  12. Else
  13.     bRet = (vbYes = MsgBox( "Do you really want to delete this directory and all subdirectroies?", vbYesNoQuestion ))
  14. End If
  15.  
  16. If bRet Then
  17.  
  18.     Set folRoot = fso.GetFolder(".")
  19.     For Each filItem In folRoot.Files
  20.         If filItem.Name <> WScript.ScriptName Then
  21.             filItem.Delete True
  22.         End If
  23.     Next
  24.    
  25.     For Each folItem In folRoot.SubFolders
  26.         folItem.Delete True
  27.     Next
  28.    
  29. End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement