Welcome, guest | Sign In | My Account | Store | Cart

Runs mshta hidden to open a file dialog and get the path of the file selected. No parameters can be passed to the dialog. EDITED: I did a subroutine with the snippet

Batch, 14 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
@echo off
call :filedialog file
echo selected  file is : "%file%
pause
exit /b


:filedialog :: &file
setlocal 
set dialog="about:<input type=file id=FILE><script>FILE.click();new ActiveXObject
set dialog=%dialog%('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);
set dialog=%dialog%close();resizeTo(0,0);</script>"
for /f "tokens=* delims=" %%p in ('mshta.exe %dialog%') do set "file=%%p"
endlocal  & set %1=%file%
Created by Antoni Gual on Wed, 25 May 2016 (MIT)
Batch recipes (42)
Antoni Gual's recipes (16)

Required Modules

  • (none specified)

Other Information and Tasks