1

Is it possible to write a batch file that will create a popup window for the user to input some specific information, and place that information into a text file? The text file should already have some text in it but I just want a couple lines to have input from the user. This is what the text file should look like:

PARTSN="USER INPUT1"
PART=blahblah
WORKSTATION=blahblah
USERID="USER INPUT2"
SIZE=blahblah

Where it says "USER INPUT1,2" is where I want the information from the user placed.

Any help would be great!

2 Answers 2

3

You can use set /p to ask the user for input:

set /p SomeVar=What is your favourite colour? 
echo Favourite colour: %SomeVar%
1
  • This is exactly what i was looking for. Thank you!!
    – John Z
    Jan 29, 2013 at 16:24
1

This will ask for four values, then print the resulting file to the desktop. It will append to the same file everytime you run this, unless you delete the file.

@echo off
set Output="%USERPROFILE%\desktop"

set /p VarOne=Enter variable one value: 
set /p VarTwo=Enter variable two value: 
set /p VarThree=Enter variable three value: 
set /p VarFour=Enter variable four value: 

REM enter your desired output here
echo Variable One   = %VarOne% >> %Output%\test.txt
echo Variable Two   = %VarTwo% >> %Output%\test.txt
echo Variable Three = %VarThree% >> %Output%\test.txt
echo Variable Four  = %VarFour% >> %Output%\test.txt

echo.
echo File has been placed %Output%
pause

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .