Is it possible to close Windows Explorer from CMD? I have a batch that does this: it will change directory, open explorer in this folder, than run a program. After the user closes the program the batch should close the explorer (or all explorers opened), continue on next folder (cd folder), run the same program in this folder and so on. Till the last folder is processed.
Share
Not from a batch file unless you want to write your own command line application that opens up a windows explorer window, and (this is the key part) somehow knows the window handle of that explorer window, so it can post a
WM_CLOSEmessage to it, which basically simulates someone closing that window.How you would determine “all the explorer windows that got opened” would be that instead of just starting
explorer.exeinstances from a command line you would do it from your own application.I think that determining the window handle (
HWNDin win32 api terms) and posting a close message would be better than trying to track process handles and terminating explorer process instances, since that could cause some side effects beyond those that you’d want.