2014-03-06 55 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