in DOS how to SET /P with a string starting with spaces

batch-file, newline, set

Solution

You have problems with a feature introduced in Vista/Win7. It strips all whitespace characters in front of a string, when using `set/p`.

But in your case it's easy, as you want to echo two lines.

@echo off
setlocal EnableDelayedExpansion
set LF=^


set /p "file=--> Please enter your filename, formatted as!LF!    [user][PC_id]"

Problem

I want to have this kind of result in a DOS batch: ``` ==> Please enter your filename, formatted as [user][PC_id] : ``` allowing the user to enter the filename after the ":" I tried a lot of combinations, but the best I can get it with ``` ECHO --^> Please enter your filename, formatted as Set /P FILE=[user][PC_id] : ``` (blank spaces before "[" are not displayed)

Original source