大网数据广告活动
Windows排障命令

rmdir

· 52CE 我爱测

Reference article for the rmdir command, which deletes a directory.

Deletes a directory.

The rmdir command can also run from the Windows Recovery Console, using different parameters. For more information, see Windows Recovery Environment (WinRE).

Note: This command is the same as the rd command.

Syntax

rmdir [<drive>:]<path> [/s [/q]]

Parameters

Parameter Description
[<drive>:]<path> Specifies the location and the name of the directory that you want to delete. Path is required. If you include a backslash () at the beginning of the specified path, then the path starts at the root directory (regardless of the current directory).
/s Deletes a directory tree (the specified directory and all its subdirectories, including all files).
/q Specifies quiet mode. Does not prompt for confirmation when deleting a directory tree. The /q parameter works only if /s is also specified.CAUTION: When you run in quiet mode, the entire directory tree is deleted without confirmation. Make sure that important files are moved or backed up before using the /q command-line option.
/? Displays help at the command prompt.
Remarks
  • You can't delete a directory that contains files, including hidden or system files. If you attempt to do so, the following message appears:

    The directory is not empty

    Use the dir /a command to list all files (including hidden and system files). Then use the attrib command with -h to remove hidden file attributes, -s to remove system file attributes, or -h -s to remove both hidden and system file attributes. After the hidden and file attributes have been removed, you can delete the files.

  • You can't use the rmdir command to delete the current directory. If you attempt to delete the current directory, the following error message appears:

    The process can't access the file because it is being used by another process.

    If you receive this error message, you must change to a different directory (not a subdirectory of the current directory), and then try again.

Examples

To change to the parent directory so you can safely remove the desired directory, type:

cd ..

To remove a directory named test (and all its subdirectories and files) from the current directory, type:

rmdir /s test

To run the previous example in quiet mode, type:

rmdir /s /q test

Related links

Source: Microsoft Learn / Windows Server documentation by Microsoft and contributors (upstream author metadata: robinharwood). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Server documentation
适用范围
Windows Server · Source date 10/16/2017
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。