How to put space before the SET / P variable in Batch? [closed]

0

I want to set the variable in the middle of the screen, but I can not put it!

|____não_funciona____|set /p variável=um    
|____funciona____|%variável%

Thanks in advance!

    
asked by anonymous 25.04.2018 / 23:36

1 answer

0
  

I am sorry, but it is not possible to define variables in the Batch starting the   value with spaces. you can even define them, but the spaces will be automatically removed.

     

But there is a way to do this by using an external utility, Editv

     

You will be playing the utility in your "System32" folder for the prompt   recognize the command of the utility, or if you prefer, leave it   Batch folder that will run the command, preferably hidden,   so it is not accidentally deleted.

     

As one of these options, use it as follows:

     

Editv32 -p "Qual o seu nome?" nome

     

Pay close attention, the Editv32 command must be the same as the   utility that you played in the System32 folder, without the need to use   the .exe extension

     

If you rename it to Edit for example, you'll have to use it like this:

'Edit -p "Qual o seu nome?" nome
     

The at the end of the command, is the name of the variable you are going to call within %%.

     

This command line will wait for a user input, and that's where   you'll put as many spaces as you want before typing the   value of the variable. and when you call the variable with %%, it will be   printed with the spaces in front.

     

-p allows you to tell something on the screen, such as a question, for example, always in double quotation marks.

     

-l allows you to limit the number of characters that will have the value of the variable.

     

example: -l 10 Indicates that the user can only enter 10 characters for the value of the variable.

     

-n forces the user to only use numbers in the value of the variable.

     

-m will mask the value of the variable in asterisks. (used for passwords)

     

-t 04 starts a count of 4 seconds, (just an example)

This is the site where you find the Package with both utilities

or Editv32 for 32bit systems and Editv64 for 64bit systems

link

    
26.04.2018 / 08:31