Jump to content

FileSelectFolder Function in a WinPE 2.0 Environment


Recommended Posts

I have seen limited discussion about trouble with the FileSelectFolder function in a WinPE 2.0 environment, but I haven't seen any solutions.

I am working on a script that requires a "Browse For Folder dialog" so that a user can input a folder of their choice. The folder could be located on any drive with a status of "READY". The script runs perfectly when in a standard Windows XP or Vista environment, however in a WinPE environment it fails because the FileSelectFolder function will not display the folder browsing dialog correctly.

Everything I have read about this leads me to believe that the FileSelectFolder function calls a dialog box that requires components delivered with Internet Explorer (and are not in WinPE's base structure).

The following example script is extremely small and only demonstrates the syntax of the FileSelectFolder function in its most basic form. However simple it may be though, I need it to work to complete my project.

FileSelectFolder("","")

If anyone has a good working solution to fix or replace the FileSelectFolder function's problems in PE, I would be very interested.

Thank you.

Link to comment
Share on other sites

Temporary Solution:

I found that the FileSelectFolder function will work as long as you specify a drive that is identified as "READY".

I created a Combo Box that loads when the program loads.

Func FindReadyDrives()
    Local $ReadyDrives = ""
    Local $CheckDrives = 26
    Local $Drives[$CheckDrives] = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
    For $i = 0 to $CheckDrives -1
        Local $Status = DriveStatus($Drives[$i] & ":\")
        if $Status = "READY" Then
            $ReadyDrives &= $Drives[$i] & ":|"
        EndIf
    Next
    GUICtrlSetData($Global_ComboBox_Variable, $ReadyDrives)
EndFunc

When a user selects this ComboBox it will open a FileSelectFolder function directed to use the drive selected as the root of the Folder Selection dialog box:

Local $Drive = GUICtrlRead($Global_ComboBox_Variable)
Local $DriverFolder = FileSelectFolder("",$Drive)

Does this work? Yes... it does. it is a dirty workaround though. If anyone knows a better way, I am very interested.

Link to comment
Share on other sites

  • 1 year later...

I have this same issue. Is there no way possible to have the FileSelectFolder basically just display all the fixed disk drives so that users can choose the drive and the folder in winpe? I'm working on something that requires the user to pick the *:\Windows folder when booted into a winpe environment, most of the time I can determine it, but sometimes with service partitions it gets complicated with several C:\windows, D:\windows, E:\windows folders existing and I need the user to be able to look at each drive to determine which is the actual windows folder vs one from a service partition.

Any help appreciated.

It works great when booted into xp/vista/win7 its just the "" start point doesn't work as it normally would when booted into winpe.

Link to comment
Share on other sites

  • 2 years later...

Hi All,

I know this topic is quite old now but I was wondering if there was ever a solution. I'm currently trying to use the FileSelectFolder function in WinPE 3.0 and it does not work properly. FileSaveDialog works fine but I really need the FileSelectFolder function for this project. I have tried adding IE into my WinPE enviorment thinking it is a prerequisite but that didnt work. Any help would be greatly appreciated.

Link to comment
Share on other sites

Update: I verified that the following syntax works in both WinPE 4 and 3.x

FileSelectFolder("Choose your folder", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")

However if you add an optional flag, the function no longer works. I am assuming it is because WinPE does not have Internet Explorer working natively in it. But you know what happens when you assume. >_<

flag [optional] 1 = Show Create Folder Button (requires IE6.0 or later)

2 = Use New Dialog Style (requires IE5.0 or later)

4 = Show Edit Control (to type a folder name)

I can live without the Create Folder Button but it would sure be nice to have. Any Ideas?

Link to comment
Share on other sites

Thanks FreeBeing for the updates. I did confirm the "4" flag worked in both WinPE 3.x and 4, but still no create folder button. I will have to do without for now.

I'm looking into adding IE and Explorer into WinPE to see if that works but I haven't found clear instructions on that process. My other option is possibly calling a VBS script and getting the return value to AutoIT. The problem again with that is VBS does not work by default in WinPE 3.x (Haven't tried 4 yet) I have to add it.

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Example", 1, "c:\Programs")
If objFolder Is Nothing Then
Wscript.Quit
End If
wscript.Echo "folder: " & objFolder.title & " Path: " & objFolder.self.path
Link to comment
Share on other sites

In fact, Windows PE 4 can support many things with adding official modules, for example it can support WMI, Net Framework 4, PowerShell, VBS, Trident (IE engine), PPPoE, etc...

To add VBS support, you can add thoses packages (into "C:Program Files (x86)Windows Kits8.0Assessment and Deployment KitWindows Preinstallation Environmentamd64WinPE_OCs" for x64) :

WinPE-Scripting.cab

Also, if your PE is in english, add lang package en-usWinPE-Scripting_en-us.cab

To add Trident (IE engine) support, you can add that package :

WinPE-HTA.cab

And the lang pack : en-usWinPE-HTA_en-us.cab

With thoses modules, now VBS works and AutoIt can download / upload files (it use IE engine).

But, it seems it's not enought to add a full Internet Explorer, FileSelectFolder with create folder option don't work.

Edit : I tried your VBS script, and the bug is the same as AutoIt.

Edit 2 : It seems a hack exists to support that "Create folder" button and folder explore, but it requires to add a file from Windows 8 (with Windows PE 4), so I think it's not legal if we don't have a Windows 8 license.

Edited by FreeBeing
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...