java删除文件夹命令行_如何从命令行删除系统驱动器中的所有文件夹

我正在尝试编写一个批处理脚本,删除系统驱动器中的所有文件夹和文件(系统文件夹,文件除外),但我卡在文件夹位上 . 这是针对Windows XP无人值守安装磁盘,我集成的其中一个更新在C:\驱动器上创建了一个随机文件夹,由于名称是随机的,我无法使用该脚本删除 . 这是我到目前为止所得到的:

@echo off

color 17

echo del-test

echo.

echo Hiding foders we want to keep

if exist "%systemdrive%\AUTOEXEC.BAT" attrib +h "%systemdrive%\AUTOEXEC.BAT"

if exist "%systemdrive%\CONFIG.SYS" attrib +h "%systemdrive%\CONFIG.SYS"

if exist "%systemdrive%\Documents and Settings" attrib +h "%systemdrive%\Documents and Settings"

if exist "%systemdrive%\Program Files" attrib +h "%systemdrive%\Program Files"

if exist "%systemdrive%\Sysprep" attrib +h "%systemdrive%\Sysprep"

if exist "%systemdrive%\temp" attrib +h "%systemdrive%\temp"

if exist "%systemdrive%\WINDOWS" attrib +h "%systemdrive%\WINDOWS"

echo Done!

echo.

echo Deleting everything that isn't hidden on the system drive

del /q %systemdrive%\*.*

dir /b c:| rd

echo Done!

echo.

echo Unhiding Folders

if exist "%systemdrive%\AUTOEXEC.BAT" attrib -h "%systemdrive%\AUTOEXEC.BAT"

if exist "%systemdrive%\CONFIG.SYS" attrib -h "%systemdrive%\CONFIG.SYS"

if exist "%systemdrive%\Documents and Settings" attrib -h "%systemdrive%\Documents and Settings"

if exist "%systemdrive%\Program Files" attrib -h "%systemdrive%\Program Files"

if exist "%systemdrive%\Sysprep" attrib -h "%systemdrive%\Sysprep"

if exist "%systemdrive%\temp" attrib -h "%systemdrive%\temp"

if exist "%systemdrive%\WINDOWS" attrib -h "%systemdrive%\WINDOWS"

echo Done!

echo.

>nul pause

顺便说一下,我只需要删除一个文件夹 . 谢谢 .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值