A while back, I wanted to have a script that would select a file or a folder in Windows Explorer. The following JScript selects the parent folder of the script that is run within Windows Explorer:
(new ActiveXObject("WScript.Shell")).Run('explorer /select,"' + WScript.ScriptFullName.replace(/[^\\\/]+$/, "") + '"');
For instance, if the above code is run in a script found at “
C:/Users/chriswest/Documents/Scripts/JScript/select_parent_folder.js“, a new Windows Explorer window will open up at “
C:/Users/chriswest/Documents/Scripts/” and the “
JScript” folder will be pre-selected. Download this file to try it out yourself!