I've managed to run batch files using the /WAIT command which loads the program then stays running until a program is closed again. I want to do this but for a folder instead of a program, but when I run the following it closes upon loading the folder contents
start /WAIT explorer.exe "path/name/here"
Could anyone help with how I can alter this to keep the batch file running until I close the folder window?
You can use a little help from
PowerShellby creating a function inside of yourbatch-file. Yes, you can usePowerShellonly, but I have no idea how much code your current script is and therefore not expecting you to re-write everything inPowerShell.The script will open the location you chose, then create the
PowerShellscript in your%temp%directory. The for loop will call thePowerShellscript every 1 second.The
PowerShellscript will loop through all open folders and simply print them. We catch the exact match usingifin the batch script, if we find that it is still active, we keep on looping until it no longer finds the folder to be active.Note, please create all other code above the
::Functionlabel.