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


Photo

how to close a folder through cmd/bat?

- - - - -

  • Please log in to reply
4 replies to this topic

#1
laz3boy

laz3boy

    Newbie

  • Member
  • 13 posts
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

#2
Geej

Geej

    Senior Member

  • Member
  • PipPipPipPip
  • 635 posts
  • 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"

#3
laz3boy

laz3boy

    Newbie

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

#4
tazosmr

tazosmr
  • Member
  • 4 posts

method 1 :

 

With CMD(command prompt):

TASKKILL /F /FI "WINDOWTITLE eq MYTITLEEEEEEEEEEEEEE" /IM explorer.exe

(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, Today, 01:35 AM.


#5
Kelsenellenelvian

Kelsenellenelvian

    WPI Guru

  • Developer
  • 8,731 posts
  • 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



How to remove advertisement from MSFN