我是cmd的新手,这是我用该程序编写的第一个代码。这些代码的一部分我没有写自己。
我的问题是我正在尝试使用CMD删除文件夹,但我无法让它工作。
我正在使用此命令:
RM /S /Q "directory"
在此代码中
cls
@ECHO OFF
color 02
title ija4779fc
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST MyFolder(2) goto MDMyFolder(2)
:CONFIRM
echo Are you sure to lock this folder? (Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo THIS IS NOT AN OPTION.
goto CONFIRM
:LOCK
ren MyFolder(2) "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto UNLOCK
:UNLOCK
echo ENTER PASSWORD:
set/p "pass=>"
if NOT %pass%== ija4779fc goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" MyFolder
echo UNLOCKED
goto PAUSE
:FAIL
Color 04
echo INCORRECT PASSWORD
DEL /S /Q "MyFolder(2)"
echo S
echo FILES DELETED
echo SYSTEM SHUTDOWN
goto end
:CORRECT
echo
:PAUSE
PAUSE
:MDMYFOLDER(2)
:END
end
MD Myfolder(2)
Thnx寻求帮助。
答案 0 :(得分:3)
删除子目录的常用方法是使用RMDIR(或RD short short)。 RD的系统文档如下(使用RD /?
生成)
Removes (deletes) a directory.
RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path
/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
tree.
/Q Quiet mode, do not ask if ok to remove a directory tree with /S