Close File Explorer Window

Page 2 of 2 FirstFirst 12
  1.    #11

    KeithM said: View Post
    The best of both our code versions, a one liner!
    Code:
    (New-Object -ComObject Shell.Application).Windows() | %{$_.quit()}
    Keith
    Excellent, that works....
      My ComputerSystem Spec

  2. Try3's Avatar
    Posts : 1,743
    Windows 10 Home x64 and Pro x86
       #12

    KeithM said: View Post
    The best of both our code versions, a one liner!
    Code:
    (New-Object -ComObject Shell.Application).Windows() | %{$_.quit()}
    Keith,

    That also closes IE. [Added later - Keith has posted a fix below]

    Denis
    Last edited by Try3; 06 Apr 2019 at 11:56.
      My ComputerSystem Spec

  3. Try3's Avatar
    Posts : 1,743
    Windows 10 Home x64 and Pro x86
       #13

    rdwray said: View Post
    I did not get yours' to work, but with your suggestion, I did find this one:
    Code:
    $a = (New-Object -comObject Shell.Application).Windows() |  ? { $_.FullName -ne $null} |
     ? { $_.FullName.toLower().Endswith('\explorer.exe') } 
    
     $a | % {  $_.Quit() }
    That one closes File explorer windows [without the side effect of closing IE].

    Thanks,

    Denis
      My ComputerSystem Spec


  4. Posts : 173
    Microsoft Windows 10 Home
       #14

    True. I remember that from XP days. Didn't mention because so few people use IE anymore. But, if you want to limit it to File Explorer windows, use:
    Code:
    (New-Object -ComObject Shell.Application).Windows() | ?{$_.name -match 'file'} | %{$_.quit()}
    Keith
      My ComputerSystem Spec

  5. Try3's Avatar
    Posts : 1,743
    Windows 10 Home x64 and Pro x86
       #15

    Keith,

    Thanks. Now filed away in my PS studies folders.

    Denis
      My ComputerSystem Spec

  6.    #16

    Wouldn't it be as easy, or easier, to Ctrl+Shift+right click Taskbar and Exit Explorer?
      My ComputersSystem Spec

  7. Try3's Avatar
    Posts : 1,743
    Windows 10 Home x64 and Pro x86
       #17

    Edwin said: View Post
    Wouldn't it be as easy, or easier, to Ctrl+Shift+right click Taskbar and Exit Explorer?
    Edwin,

    The OP needs to do it within a script.

    All the best,
    Denis
      My ComputerSystem Spec


  8. Posts : 173
    Microsoft Windows 10 Home
       #18

    Edwin said: View Post
    Wouldn't it be as easy, or easier, to Ctrl+Shift+right click Taskbar and Exit Explorer?
    Also, that kills the shell process, which the OP wanted to avoid.

    Keith
      My ComputerSystem Spec

  9. Brink's Avatar
    Posts : 38,982
    64-bit Windows 10 Pro build 18898
       #19

    Hello @rdwray,

    If you are wanting a way to close all explorer instances and restart the explorer process, then you might see if the context menu added by the tutorial below may work for you for this.

    Restart Explorer Context Menu - Add in Windows 10
      My ComputersSystem Spec


 
Page 2 of 2 FirstFirst 12

Related Threads
Hello, when I open the File Explorer, it opens in full-screen mode. I can minimize it but not resize the window. If I click the top-right corner symbol of two squares, the file explorer window gets smaller but the text in it flashes on and off...
Hello everyone. I have a laptop that runs on win 10 x64 ver 1809 build 17763 I have some problems that I think are file explorer-related. 1) The file explorer often randomly closes without any crash. I can still use my laptop afterwards. I...
Hi. I have a videos folder. I am checking and deleting unwanted videos by opening each for few seconds and deleting ones I don't like. Problem is that when I close the player and want to delete the video, the explorer window is no more...
When I try to autoplay a DVD, the Windows DVD Player will load and then immediately close. When I view the /VIDEO_TS directory in the DVD the same event happens. This behavior was not true in the past. What is going on? I am running Windows 10....
Solved Resizing File Explorer Window in General Support
When I open File Explorer the window opens maximized and will not let me resize it. The minimize (-) and close (x) buttons work ok but the center button doesn't do anything when picked. I am new to windows 10, my old system was XP. Any help/ideas...
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 00:39.
Find Us