繁体   English   中英

在我的批处理脚本中出现变量问题

[英]Issue with a variable in my batch script

我希望我的脚本:

  • 接受变量
  • 使用该变量作为输入创建路径
  • 显示路径
  • 显示目录的内容

以下代码有什么问题? ECHO语句只是打印Your directory is set to ; DIR声明按预期工作。

@ECHO OFF
SET custompath = "C:\Users\%1"
ECHO  Your directory is set to %custompath%
DIR %custompath%

这是=周围的空间。

@ECHO OFF
SET custompath="C:\Users\%1"
ECHO  Your directory is set to %custompath%
DIR %custompath%

查看这篇文章

就个人而言,我会这样做:

@ECHO OFF
SET /P "custompath=Enter a custom windows path: "
ECHO Showing contents of directory ^"%custompath%^"
DIR /b "%custompath%"
pause

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM