Alex Rivera | Logout

In batch, how do I create spaces at the beginning of a input prompt string?

Asked 2012-03-25T22:20:42.767
22

Let's say I have a batch file that has "padding" in it, and I want to indent the beginning of the prompt string for the user to type in. If I use spaces, it will not show up when run, it just ignores the spaces. This script for an example:

@echo off

echo.
echo.
echo    Hi.
echo    Please input something.
echo.
set /P input=   

After the = there is three spaces, and what I expect is that the marker for input is away from the edge of the command box, however these spaces are ignored.

How can I fix this problem? I am using Windows 7 SP1.

Edit
Report

1 Answer

0

This works in every Windows OS from W2K + I've tried, if it suits you. You could just use a : in the string.

set /p "var=Please input something: "
echo.%var%
answered 2013-05-28T11:53:18.717

Your Answer