[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
我本来是打算用个批处理,实现开机后台自动清除当前所有盘下面的一些目录(因为要求对所有电脑的通用性高一点,所以盘符比较多)。比如:

del /f /s /q /ah "c:\RECYCLER\*.*" >nul 2>nul
del /f /s /q /a "c:\RECYCLER\*.*" >nul 2>nul
rd /s /q "c:\RECYCLER" >nul 2>nul

del /f /s /q /ah "d:\RECYCLER\*.*" >nul 2>nul
del /f /s /q /a "d:\RECYCLER\*.*" >nul 2>nul
rd /s /q "d:\RECYCLER" >nul 2>nul

del /f /s /q /ah "e:\RECYCLER\*.*" >nul 2>nul
del /f /s /q /a "e:\RECYCLER\*.*" >nul 2>nul
rd /s /q "e:\RECYCLER" >nul 2>nul

del /f /s /q /ah "f:\RECYCLER\*.*" >nul 2>nul
del /f /s /q /a "f:\RECYCLER\*.*" >nul 2>nul
rd /s /q "f:\RECYCLER" >nul 2>nul

del /f /s /q /ah "g:\RECYCLER\*.*" >nul 2>nul
del /f /s /q /a "g:\RECYCLER\*.*" >nul 2>nul
rd /s /q "g:\RECYCLER" >nul 2>nul

del /f /s /q /ah "h:\RECYCLER\*.*" >nul 2>nul
del /f /s /q /a "h:\RECYCLER\*.*" >nul 2>nul
rd /s /q "h:\RECYCLER" >nul 2>nul

del /f /s /q /ah "i:\RECYCLER\*.*" >nul 2>nul
del /f /s /q /a "i:\RECYCLER\*.*" >nul 2>nul
rd /s /q "i:\RECYCLER" >nul 2>nul

del /f /s /q /ah "j:\RECYCLER\*.*" >nul 2>nul
del /f /s /q /a "j:\RECYCLER\*.*" >nul 2>nul
rd /s /q "j:\RECYCLER" >nul 2>nul

del /f /s /q /ah "k:\RECYCLER\*.*" >nul 2>nul
del /f /s /q /a "k:\RECYCLER\*.*" >nul 2>nul
rd /s /q "k:\RECYCLER" >nul 2>nul

TOP

笔记本的xp系统,我的电脑里面,即使不插入存储卡,也会出现 可移动磁盘f:

这种笔记本,刚刚装完ghost版本的xp系统,在我的电脑里面,会出现可移动磁盘f:(这个应该是笔记本内置读卡器的盘符)。
即使不插入存储卡,也会出现这个 可移动磁盘f:


在以上这种情况下,只要执行
rd /s /q "f:\RECYCLER" >nul 2>nul
就会弹出窗口,让你选择才能继续运行这个bat文件。

TOP

28# ygqiang
樓主上面的代碼應該能符合您的需求了!
因為除了固定盤符:\RECYCLER,如果有移動盤符:\RECYCLER也可一併刪除!!
dennisle 发表于 2011-6-1 09:09


我说的很清楚了,你还没有明白?

笔记本的xp系统,我的电脑里面,即使不插入存储卡,也会出现 可移动磁盘f:
这种笔记本,刚刚装完ghost版本的xp系统,在我的电脑里面,会出现可移动磁盘f:(这个应该是笔记本内置读卡器的盘符)。
即使不插入存储卡,也会出现这个 可移动磁盘f:


在以上这种情况下,只要执行:
rd /s /q "f:\RECYCLER" >nul 2>nul
就会弹出窗口,让你选择“继续”按钮,才能继续运行这个bat文件!!!!!!

TOP

只要将读卡器不插存储卡,直接插到电脑上,就会出现一个盘符

这样试验环境就出来了

TOP

如果这个盘符是g:

del /f /s /q /ah "g:\RECYCLER\*.*" >nul 2>nul
del /f /s /q /a "g:\RECYCLER\*.*" >nul 2>nul
rd /s /q "g:\RECYCLER" >nul 2>nul

这个运行,就会出问题(弹出窗口)

如何不让这个窗口弹出呢?

TOP

你用第一个批处理测试
如果没任何显示,基本可以断定是精简残废版xp,没辙了

我这里插上读卡器,再插一个内存卡
运行后得到结果

所以运行第2个随便怎样是不会有弹出窗口的
fastslz 发表于 2011-6-1 22:08


我装的是ghost版本的xp系统  电脑公司的。

TOP

换了一个ghost版本的xp系统,也是电脑公司的。

故障现象消失。

说明还是xp系统的问题。以前那个是精简版本ghost的xp系统!

TOP

新的问题:

for /f "skip=1 delims=" %%a in ('Wmic LogicalDisk Where "DriveType='2' and SupportsDiskQuotas='FALSE'" Get DeviceID') do call :s1 %%a


goto:eof

:s1

if "%~1"=="" goto:eof

if exist "%1\RECYCLER" del /f /s /q /ah "%1\RECYCLER\*.*" >nul 2>nul
if exist "%1\RECYCLER" del /f /s /q /a "%1\RECYCLER\*.*" >nul 2>nul
if exist "%1\RECYCLER" rd /s /q "%1\RECYCLER" >nul 2>nul

if exist "%1\Recycled" del /f /s /q /ah "%1\Recycled\*.*" >nul 2>nul
if exist "%1\Recycled" del /f /s /q /a "%1\Recycled\*.*" >nul 2>nul
if exist "%1\Recycled" rd /s /q "%1\Recycled" >nul 2>nul

if exist "%1\kvideo_cache" del /f /s /q /ah "%1\kvideo_cache\*.*" >nul 2>nul
if exist "%1\kvideo_cache" del /f /s /q /a "%1\kvideo_cache\*.*" >nul 2>nul
if exist "%1\kvideo_cache" rd /s /q "%1\kvideo_cache" >nul 2>nul

if exist "%1\$RECYCLE.BIN" del /f /s /q /ah "%1\$RECYCLE.BIN\*.*" >nul 2>nul
if exist "%1\$RECYCLE.BIN" del /f /s /q /a "%1\$RECYCLE.BIN\*.*" >nul 2>nul
if exist "%1\$RECYCLE.BIN" rd /s /q "%1\$RECYCLE.BIN" >nul 2>nul

goto:eof

这个命令只能清除  移动磁盘盘符  下的相关目录。

如果清除  本地磁盘盘符  下的?》

TOP

瞧瞧你一个残废XP倒腾了多少人
这个和问题已经跑题了,之前你不是说移动磁盘盘符吗,所以只处理移动磁盘盘符
@echo off
for /f "skip=1 delims=" %%a in ('Wmic LogicalDisk Where "DriveType='3'" Get DeviceID' ...
fastslz 发表于 2011-6-2 06:56


呵呵,我用的是  “电脑公司 ghost xp sp3急速纯净版2010.06”这个版本的。

TOP

更新:运行下面这个bat批处理文件。
系统还是“电脑公司 ghost xp sp3急速纯净版2010.06”这个版本

好像已经不弹出窗口了。


for /f "skip=1 delims=" %%a in ('Wmic LogicalDisk Where "DriveType='2' and SupportsDiskQuotas='FALSE'" Get DeviceID') do call :s1 %%a


for /f "skip=1 delims=" %%a in ('Wmic LogicalDisk Where "DriveType='3'" Get DeviceID') do call :s1 %%a




:s1

if "%~1"=="" goto:eof

if exist "%1\RECYCLER" del /f /s /q /ah "%1\RECYCLER\*.*" >nul 2>nul
if exist "%1\RECYCLER" del /f /s /q /a "%1\RECYCLER\*.*" >nul 2>nul
if exist "%1\RECYCLER" rd /s /q "%1\RECYCLER" >nul 2>nul

if exist "%1\Recycled" del /f /s /q /ah "%1\Recycled\*.*" >nul 2>nul
if exist "%1\Recycled" del /f /s /q /a "%1\Recycled\*.*" >nul 2>nul
if exist "%1\Recycled" rd /s /q "%1\Recycled" >nul 2>nul

if exist "%1\kvideo_cache" del /f /s /q /ah "%1\kvideo_cache\*.*" >nul 2>nul
if exist "%1\kvideo_cache" del /f /s /q /a "%1\kvideo_cache\*.*" >nul 2>nul
if exist "%1\kvideo_cache" rd /s /q "%1\kvideo_cache" >nul 2>nul

if exist "%1\$RECYCLE.BIN" del /f /s /q /ah "%1\$RECYCLE.BIN\*.*" >nul 2>nul
if exist "%1\$RECYCLE.BIN" del /f /s /q /a "%1\$RECYCLE.BIN\*.*" >nul 2>nul
if exist "%1\$RECYCLE.BIN" rd /s /q "%1\$RECYCLE.BIN" >nul 2>nul

goto:eof

TOP

返回列表