Jump to content
Sign in to follow this  
bkazdan

FileSelectFolder Function in a WinPE 2.0 Environment

Recommended Posts

bkazdan

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.

Share this post


Link to post
Share on other sites
bkazdan

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.

Share this post


Link to post
Share on other sites
tomatthe

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.

Share this post


Link to post
Share on other sites
fcg

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.

Share this post


Link to post
Share on other sites
AZJIO

Try to register all the DLLs

#include <File.au3>
$sPath = @SystemDir & '\'
$aFileList = _FileListToArray($sPath, '*.dll', 1)
; $s = ''
For $i = 1 To $aFileList[0]
    RunWait('regsvr32.exe /s ' & $Path & $aFileList[$i])
    ; $s &= 'regsvr32.exe /s ' & $sPath & $aFileList[$i] & @LF
Next
; MsgBox(0, 'aFileList', $s)

Share this post


Link to post
Share on other sites
FreeBeing

I use FileSelectFolder with Windows PE 4 and I must set the "start folder" to "Computer" to get that function working :

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

Share this post


Link to post
Share on other sites
AZJIO

HKEY_CLASSES_ROOTCLSID{20D04FE0-3AEA-1069-A2D8-08002B30309D}

It is present in the registry?

Share this post


Link to post
Share on other sites
FreeBeing

Yes, that key exists into Windows PE 4, it works with that "start folder", as I said ;)

Share this post


Link to post
Share on other sites
fcg

Thank you both for the feedback I will try in WinPE 4.0

Share this post


Link to post
Share on other sites
fcg

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?

Share this post


Link to post
Share on other sites
FreeBeing

Indeed options 1 and 2 don't work, but 4 seems to be OK.

Share this post


Link to post
Share on other sites
FreeBeing

I would like to add :

If you want to explore network shares into Windows PE, you can use :

FileSelectFolder("Choose your network share", "::{208D2C60-3AEA-1069-A2D7-08002B30309D}")

Share this post


Link to post
Share on other sites
fcg

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

Share this post


Link to post
Share on other sites
FreeBeing

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.