Using "HTA input forms" in Batch files

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Meerkat
Posts: 89
Joined: 19 Jul 2015 02:27
Location: Philippines

Re: Using "HTA input forms" in Batch files

#16 Post by Meerkat » 20 Aug 2015 08:01

OperatorGK wrote:Guys from one Russian forum done it before (folder selection menu):

Code: Select all

@echo off 
for /f "usebackq delims=" %%i in (
    `@"%systemroot%\system32\mshta.exe" "javascript:var objShellApp = new ActiveXObject('Shell.Application');var Folder = objShellApp.BrowseForFolder(0, 'Select Folder:',1, '::{20D04FE0-3AEA-1069-A2D8-08002B30309D}');try {new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(Folder.Self.Path)};catch (e){};close();" ^
    1^|more`
) do set sFolderName=%%i
if defined sFolderName (
    echo Folder : %sFolderName%
) else (
    echo Folder isn't selected
)
cd %sFolderName%


Hmm... Is there a way to make the looooong one line "IN part" to multi line? This works:

Code: Select all

@echo off

for %%I in (
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
17 18
19
) do echo %%I
pause


Meerkat

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: Using "HTA input forms" in Batch files

#17 Post by foxidrive » 20 Aug 2015 09:09

It may not be what you want, but it works. :)

Code: Select all

@echo off

set v=@"%systemroot%\system32\mshta.exe"
set v=%v% "javascript:var objShellApp = new ActiveXObject
set v=%v%('Shell.Application');var Folder = objShellApp.
set v=%v%BrowseForFolder(0, 'Select Folder:',1, '
set v=%v%::{20D04FE0-3AEA-1069-A2D8-08002B30309D}');try
set v=%v%{new ActiveXObject('Scripting.FileSystemObject')
set v=%v%.GetStandardStream(1).Write(Folder.Self.Path)};
set v=%v%catch (e){};close();"

@echo off
for /f "usebackq delims=" %%i in (
    `%v%  1^|more`
) do set "sFolderName=%%i"
if defined sFolderName (
    echo Folder : "%sFolderName%"
) else (
    echo Folder isn't selected
)
cd /d "%sFolderName%"

pause

Meerkat
Posts: 89
Joined: 19 Jul 2015 02:27
Location: Philippines

Re: Using "HTA input forms" in Batch files

#18 Post by Meerkat » 20 Aug 2015 22:08

Thanks! Ill accept that. :D

Aacini
Expert
Posts: 1712
Joined: 06 Dec 2011 22:15
Location: México City, México

Re: Using "HTA input forms" in Batch files

#19 Post by Aacini » 03 Sep 2021 11:09

I updated the code in this (old) thread to fix some minor errors...

Antonio

Post Reply