omegastripes

close_unwanted_explorer_windows.vbs

May 15th, 2016
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. strUserFolder = LCase(CreateObject("WScript.Shell").ExpandEnvironmentStrings("%userprofile%"))
  2. Do
  3.     For Each objShellWindow In CreateObject("Shell.Application").Windows
  4.         Set objDocument = objShellWindow.Document
  5.         If InStr(TypeName(objDocument), "IShellFolderViewDual") Then
  6.             strPath = LCase(objDocument.Folder.Self.Path)
  7.             Select Case True
  8.                 Case strPath = "::{20d04fe0-3aea-1069-a2d8-08002b30309d}"
  9.                 Case strPath = "c:\"
  10.                 Case InStr(strPath, "d:\") > 0
  11.                 Case InStr(strPath, strUserFolder) > 0
  12.                 Case Else
  13.                     objShellWindow.Quit
  14.             End Select
  15.         End If
  16.     Next
  17.     Wscript.Sleep 100
  18. Loop
Add Comment
Please, Sign In to add comment