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!

Categories: BlogJScript

1 Comment

Web Design Macclesfield · June 25, 2012 at 10:00 AM

Straightforward… potentially useful, thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *