However, I don't want to have to use the command line to create these rooted explorers. I wanted a little GUI that would present a folder section dialog and then have it run explorer for the selected folder. I did this using Windows Scripting Host (WSH) because I knew it could do what I wanted and that everyone could use the result because everyone with Windows XP (and I assume Vista) has WSH. What I did not know how to do was how to program WSH.
When you don't know how to use a language or toolkit and you want to code something really quickly it is best to find code that does something similar to what you want and then hack it. I was lucky and found some sample code and below is the result. Save the code to the file "explore.vbe" and to run it just open it -- I have a shortcut in my Quick Launch toolbar.
set shell = WScript.CreateObject("WScript.Shell")Wow, this is ugly code. But it does work.
shell.run "explorer.exe /e,/root," & BrowseForFolder("Windows Explorer Root")
'Uses the "Shell.Application" (only present in Win98 and newer)
'to bring up a file/folder selection window. Falls back to an
'ugly input box under Win95.
Const ssfPERSONAL = 5 'My Documents
Const ssfDRIVES = 17 'My Computer
Const SFVVO_SHOWALLOBJECTS = 1
Const SFVVO_SHOWEXTENSIONS = 2
Dim sh, fol, fs, lngView, strPath
Set sh = CreateObject("Shell.Application")
If Instr(TypeName(sh), "Shell") = 0 Then
BrowseForFolder = InputBox(strPrompt, "Select Folder", CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName))
Set fs = CreateObject("Scripting.FileSystemObject")
lngView = SFVVO_SHOWALLOBJECTS Or SFVVO_SHOWEXTENSIONS
strPath = ""
Set fol = sh.BrowseForFolder(&0, strPrompt, lngView, ssfDRIVES)
On Error Resume Next
strPath = fol.ParentFolder.ParseName(fol.Title).Path
'An error occurs if the user selects a drive instead of a folder
If Err.Number <> 0 Then
BrowseForFolder = Left(Right(fol.Title, 3), 2) & "\"
BrowseForFolder = strPath