本文介绍了在DOS下如何设置/ p用字符串开头空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有这种结果在DOS批处理:

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)

推荐答案

您有在Vista中/ Win7的引入的功能的问题。结果
它剔除所有空格字符的字符串的前面,当使用设置/ P

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]"

这篇关于在DOS下如何设置/ p用字符串开头空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 12:26