Board logo

标题: 关于set指令 [打印本页]

作者: xuanliang     时间: 2004-7-1 00:00    标题: 关于set指令

set/p xx=del c:\.>xx.bat

是什么意思呢?

请教
作者: Climbing     时间: 2004-7-2 00:00
你肯定是抄错了。
应该是这样的:
set /p xx=
del c:\.>xx.bat

/p参数的作用是将用户输入的一行内容作为环境变量的值,这应该是2000/xp/2003下dos窗口的set命令。不知道老版本的dos支持不支持这个参数。

Windows 2003下的set帮助(set /?):
...
Two new switches have been added to the SET command:

    SET /A expression
    SET /P variable=[promptString]
...
The /P switch allows you to set the value of a variable to a line of input
entered by the user.  Displays the specified promptString before reading
the line of input.  The promptString can be empty.

下面是我试用的过程:
C:\Documents and Settings\xxx>set /p xx=Please Input:
Please Input: del c:\.>x.bat
^^^^^^^^
系统自动提示内容

:: 显示xx环境变量的内容:
C:\Documents and Settings\xxx>set xx
xx= del c:\.>x.bat