2014-03-06 119 views
0

我是cmd的新手,这是我使用该程序编写的第一个代码。这部分代码我没有自己写过。如何使用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的帮助。

回答

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 
+0

谢谢! :)它帮助了很多。 – Tuller45