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
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%
|