Window from Batch? [SOLVED]

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
MikeInThe901
Posts: 6
Joined: 24 Apr 2023 11:13

Window from Batch? [SOLVED]

#1 Post by MikeInThe901 » 01 Aug 2023 06:36

I can use the code below in a batch file to get keyboard input from a command prompt. Is it possible to do the same thing but get the input from a Window instead of a prompt?

set /p Var=What is your name:

Thanks!
Last edited by MikeInThe901 on 01 Aug 2023 10:00, edited 1 time in total.

Batcher
Posts: 74
Joined: 16 Apr 2009 10:36

Re: Window from Batch?

#2 Post by Batcher » 01 Aug 2023 08:27

test-1.bat

Code: Select all

@echo off
for /f "delims=" %%i in ('powershell "Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::InputBox('What is your name:')"') do (
    set "Var=%%i"
)
echo,%Var%
pause

Batcher
Posts: 74
Joined: 16 Apr 2009 10:36

Re: Window from Batch?

#3 Post by Batcher » 01 Aug 2023 08:46

test-2.bat

Code: Select all

@echo off
>"%temp%\GetInput.vbs" echo WSH.Echo InputBox("What is your name:")
for /f "delims=" %%i in ('cscript "%temp%\GetInput.vbs" //nologo //e:vbscript') do (
    set "Var=%%i"
)
echo,%Var%
pause

MikeInThe901
Posts: 6
Joined: 24 Apr 2023 11:13

Re: Window from Batch?

#4 Post by MikeInThe901 » 01 Aug 2023 10:00

Thank you again Batcher! I appreciate your help.

Post Reply