Sometimes you need to open multiple Explorer windows from a batch file. Perhaps because two directories need to be compared by a human, rather than by a computer.

I’ve had to do it multiple times for projects in the past, and so does a longtime reader, who wasn’t able to find how in a Google search.

You might kick yourself after you see how.

Rather than using explorer.exe pathname, use the command start pathname. Here’s an example:

start c:\documents

start e:\backup

Then you’ll get two windows. If you use explorer.exe instead of start, one opens in a window, then the second one immediately opens over the first, in the same window.

Yeah, it’s that simple, though not obvious.

If you want the batch file to pause for human action and then continue afterward, use the pause command. I used to do that when I was staging web servers. Different servers, based on different complex criteria, needed different files. It was easier to just state the rules and let a human place the file rather than try to do it programmatically. Something like this:

echo Drag the right config file to each server. Even-numbered servers get config 1. Odd-numbered servers get config 2, unless they’re a prime number and it happens to be Tuesday, in which case they get config 3.

start “\\server1\c$\config”

start “\\server2\c$\config”

start “\\server3\c$\config”

start “c:\configs”

pause

for %%i in (server1 server2 server3) do xcopy /s c:\webkit “\\%%i\c$”

script continues….

If spaces appear anywhere in the pathname, put them in quotes. They do no harm if they’re unnecessary.

If you like stuff like this, I’ve collected most of my scripting resources in a single post about scripting Windows sysadmin tasks.