Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


how to close a folder through cmd/bat?

- - - - -

  • Please log in to reply
4 replies to this topic




  • Member
  • 13 posts
  • Joined 21-September 08
Let's say I have a folder in drive C: named X
I can open that folder from a cmd window with the command start C:\X
but what If I want to close the same opened folder through cmd or a bat ,
How can I do it??
thanx in advance..

Edited by laz3boy, 27 September 2009 - 05:20 AM.

How to remove advertisement from MSFN



    Senior Member

  • Member
  • PipPipPipPip
  • 635 posts
  • Joined 01-January 08
  • OS:XP Pro x86
  • Country: Country Flag
Try NirCmd.exe. Read the help file.

To close all opened explorer folders, syntax : nircmd.exe win close class "CabinetWClass"

To close only a particular folder, say My Picture folder ( I have My Pictures & My Music folders open), syntax: nircmd.exe win close title "My Pictures"




  • Member
  • 13 posts
  • Joined 21-September 08
Wow!, this gets the job done man!!, thanx a lot ~~!!
Its a nice little utility and it helps in many other stuff
thanks again.


  • Member
  • 3 posts
  • Joined 26-June 09

method 1 :


With CMD(command prompt):


(just change MYTITLEEEEEEEEEEEEEE with the opened folder's title [case-sensitive])



method 2 :

open a new text document and enter this code:

Set oShell = CreateObject("WScript.Shell")
If oShell.AppActivate("YourWindowTITLEEEEEEEEEEEEE") Then
WScript.Sleep 100
oShell.SendKeys "%{F4}"
End If

then save that file as yourfile.vbs and put to your desired path.
Then run the Command:
%windir%\system32\cmd.exe /C "START /WAIT CScript C:\ExampleFolder\yourfile.vbs //NoLogo"


(note,that you should change "YourWindowTITLEEE" and "yourFileName.vbs" to whatever you want. Below is just an

Edited by tazosmr, 11 July 2014 - 01:35 AM.



    WPI Guru

  • Developer
  • 8,710 posts
  • Joined 18-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Thank you for answering a 5 year old post.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users