我正在尝试创建一个批处理文件,该文件将目录的路径设置在前面,或者将其从默认路径添加到路径的后面。要将目录放在前面,请放置 /f 或 /F,而要将其添加到后面,则不要包含 /f 或 /F。每次我使用示例目录时,当我在前面使用 /f 或不使用它时,它只是将它放在前面。请帮我更正。谢谢。
@ECHO OFF
ECHO Press Y or y for an explanation on how to use this file.
ECHO Press N or n to continue without help.
REPLY64
:TOP
IF "%1"=="" GOTO DEFAULT
IF NOT "%1"=="" GOTO ADD
IF NOT "%1"=="" GOTO ADD
IF "%1"=="/f" GOTO FRONT
IF "%1"=="/F" GOTO FRONT
IF ERRORLEVEL 121 GOTO F1
IF ERRORLEVEL 110 GOTO TOP
IF ERRORLEVEL 89 GOTO F1
IF ERRORLEVEL 78 GOTO TOP
:F1
ECHO SETPATH /F subdirectory1 subdirectory 2 or SETPATH /f subdirectory1 subdirectory 2.
ECHO The /F or /f tells the batch file to add the subdirectory name in front of the existing path.
ECHO If the command is keyed in without /F or /f, each subdirectory will be added to the end.
GOTO END
:ADD
IF "%1"=="" GOTO END
PATH= %PATH%;%1
SHIFT
GOTO ADD
:FRONT
SHIFT
IF "%1"=="" GOTO END
PATH=%1;%PATH%
GOTO FRONT
:DEFAULT
CALL \MYPATH.BAT
:END