I want my script to:
What is wrong with the following code? The ECHO
statement just prints Your directory is set to
; the DIR
statement works as expected.
@ECHO OFF
SET custompath = "C:\Users\%1"
ECHO Your directory is set to %custompath%
DIR %custompath%
It's the space around the =
.
@ECHO OFF
SET custompath="C:\Users\%1"
ECHO Your directory is set to %custompath%
DIR %custompath%
Check this post .
Personally, I would do it this way:
@ECHO OFF
SET /P "custompath=Enter a custom windows path: "
ECHO Showing contents of directory ^"%custompath%^"
DIR /b "%custompath%"
pause
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.