2

I' m trying to write a batch file that close an open folder, for example pippo. I've tryed:

net file pippo /close

and:

net file C:/pippo / close

but they didn' t work.

Any ideas ?

VinceLomba
  • 398
  • 2
  • 8
  • 18
  • 1
    that's a local folder. what makes you think you can "close" a local folder? if you mean close an explorer window that happens to have that folder in-view, then you're going to need something entirely different. – Marc B Jul 27 '15 at 21:36
  • Possible duplicate : http://stackoverflow.com/questions/24911112/close-folders-window-with-batch-file – SachaDee Jul 28 '15 at 18:49

4 Answers4

3

solution for < 8 :

TASKKILL /F /FI "WINDOWTITLE eq %DirectoryPath%" /IM explorer.exe

For windows 8(.1)/10

TASKKILL /F /FI "WINDOWTITLE eq %DirectoryName%" /IM explorer.exe
TSnake41
  • 405
  • 3
  • 8
2

This hybrid code [Batch/Vbscript] try to close all opened folders:

@echo off
Set VBSFILE=%Temp%\CloseAllOpenedFolders.vbs
(
echo Option Explicit
echo Dim shell,oWindows,j
echo Set shell = CreateObject("Shell.Application"^)
echo set oWindows = shell.windows
echo for j = 0 to oWindows.count - 1
echo   oWindows.item(j^).quit
echo next
echo set shell = nothing
echo set oWindows = nothing
)>%VBSFILE%
Start /Wait %VBSFILE%
Hackoo
  • 18,337
  • 3
  • 40
  • 70
1

Need to loop from high to low

Option Explicit

Dim shell,oWindows,j

Set shell = CreateObject("Shell.Application")

Set oWindows = shell.windows

for j = oWindows.count - 1 to 0 Step -1

    oWindows.item(j).quit
    Wscript.Sleep 50

next

set shell = nothing

set oWindows = nothing
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
George Lee
  • 11
  • 1
-7

Next code should work (but I did not tested it)

md (folder location/path)

Adrian Maire
  • 14,354
  • 9
  • 45
  • 85
  • 2
    `md` is short for Make Directory. It has absolutely nothing to do with closing a directory. – Tim Jul 27 '15 at 21:42
  • 5
    I generally try not to downvote answers from people who have less than 100 rep, but because of your pleading for us to not downvote you (combined with the fact that your answer is almost the exact opposite of what he wants) I'm going to make an exception. – SomethingDark Jul 27 '15 at 22:20
  • 1
    You obviously still haven't learnt your lesson here. Please *please* see [ask] & [answer]. Providing you read those two pages, you will find that your posts are better received as you'll have better knowledge of what is acceptable here. – AStopher Dec 20 '15 at 18:06