簡體   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