? BrowseFolder( "C:\Program Files", True ) ? BrowseFolder( "My Computer", False ) ? BrowseFolder( ) Function BrowseFolder( Optional $myStartLocation, Optional $blnSimpleDialog ) ; This function generates a Browse Folder dialog ; and returns the selected folder as a string. ; ; Optional Arguments: ; myStartLocation [string] start folder for dialog, or "My Computer", ; or empty to open in "Desktop\My Documents" ; blnSimpleDialog [boolean] if False, an additional text field will be ; displayed where the folder can be selected ; by typing the fully qualified path ; ; Returns: [string] the fully qualified path to the selected folder ; ; Based on the Hey Scripting Guys article ; "How Can I Show Users a Dialog Box That Only Lets Them Select Folders?" ; http://www.microsoft.com/technet/scriptcenter/resources/qanda/jun05/hey0617.mspx ; ; Function written by Rob van der Woude ; http://www.robvanderwoude.com $MY_COMPUTER = &11 $WINDOW_HANDLE = 0 ; Must ALWAYS be 0 Dim $numOptions, $objFolder, $objFolderItem Dim $objPath, $objShell, $strPath, $strPrompt ; Set the options for the dialog window $strPrompt = "Select a folder:" If blnSimpleDialog = False $numOptions = &10 ; Additional text field to type folder path Else $numOptions = 0 ; Simple dialog EndIf ; Create a Windows Shell object $objShell = CreateObject( "Shell.Application" ) ; If specified, convert "My Computer" to a valid ; path for the Windows Shell's BrowseFolder method If $myStartLocation = "My Computer" $objFolder = $objShell.Namespace( $MY_COMPUTER ) $objFolderItem = $objFolder.Self $strPath = $objFolderItem.Path Else $strPath = $myStartLocation EndIf $objFolder = $objShell.BrowseForFolder( $WINDOW_HANDLE, $strPrompt, $numOptions, $strPath ) ; Quit if no folder was selected If $objFolder = Nothing $BrowseFolder = "" Return EndIf ; Retrieve the path of the selected folder $objFolderItem = $objFolder.Self $objPath = $objFolderItem.Path ; Return the path of the selected folder $BrowseFolder = $objPath EndFunction