Search code examples
windowsbatch-filevbscriptcmdfolderbrowserdialog

Folder chooser dialog from a Windows batch script


How do I implement the following code:

@if (@a==@b) @end /*

:: fchooser2.bat
:: batch portion

    @echo off
    setlocal

    for /f "delims=" %%I in ('cscript /nologo /e:jscript "%~f0"') do (
        echo You chose %%I
    )

    goto :EOF

    :: JScript portion */

    var shl = new ActiveXObject("Shell.Application");
    var folder = shl.BrowseForFolder(0, "Please choose a folder.", 0, 0x00);
    WSH.Echo(folder ? folder.self.path : '');

With the following result:

Result

In this code:

@echo off 
color a

app\arc x -ep1 -i2 -w. -dp.\OUTLAST_REPACK_GZK\Outlast DATA_0.bin -msrep:d
app\arc x -ep1 -i2 -w. -dp.\OUTLAST_REPACK_GZK\Outlast\_CommonRedist DATA_1.bin -msrep:d
app\arc x -ep1 -i2 -w. -dp.\OUTLAST_REPACK_GZK\Outlast\OLGame DATA_2.bin -msrep:d
app\arc x -ep1 -i2 -w. -dp.\OUTLAST_REPACK_GZK\Outlast\Engine DATA_3.bin -msrep:d
app\arc x -ep1 -i2 -w. -dp.\OUTLAST_REPACK_GZK\Outlast\Binaries DATA_4.bin -msrep:d

To select the destination folder to extract a file to in batch.

Like the following or another way, I don't know how to do this:

app\arc x -ep1 -i2 -w. -dp.\%FCHOOSER2%\Outlast DATA_0.bin -msrep:d

Solution

  • This should work - but I am unsure about the -dp switch and syntax with the period. Check the arc.exe documentation.

    The pause will allow you to read any error messages.

    @if (@a==@b) @end /*
    
    :: fchooser2.bat
    :: batch portion
    
        @echo off
        setlocal
    
        for /f "delims=" %%I in ('cscript /nologo /e:jscript "%~f0"') do (
            echo You chose "%%I"
            set "folder=%%I"
        )
    
    
    @echo off 
    color a
    
    
    
    app\arc x -ep1 -i2 -r -w. -dp"%folder%\Outlast" DATA_0.bin -msrep:d
    app\arc x -ep1 -i2 -r -w. -dp"%folder%\Outlast\_CommonRedist" DATA_1.bin -msrep:d
    app\arc x -ep1 -i2 -r -w. -dp"%folder%\Outlast\OLGame" DATA_2.bin -msrep:d
    app\arc x -ep1 -i2 -r -w. -dp"%folder%\Outlast\Engine" DATA_3.bin -msrep:d
    app\arc x -ep1 -i2 -r -w. -dp"%folder%\Outlast\Binaries" DATA_4.bin -msrep:d
    pause
    
        goto :EOF
    
        :: JScript portion */
    
        var shl = new ActiveXObject("Shell.Application");
        var folder = shl.BrowseForFolder(0, "Please choose a folder.", 0, 0x00);
        WSH.Echo(folder ? folder.self.path : '');