找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
楼主: ygqiang

[已解决]批处理删除文件夹遇到没插存储卡的可移动磁盘如何不弹窗口?

[复制链接]
 楼主| 发表于 2011-6-1 09:13:52 | 显示全部楼层
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文件!!!!!!
发表于 2011-6-1 09:56:25 | 显示全部楼层
看来批是解决不了你这个问题,找找其他工具吧。。。
发表于 2011-6-1 11:43:14 | 显示全部楼层

  1. @echo off
  2. for /f "skip=1 delims=" %%a in ('Wmic LogicalDisk Where "DriveType='2' and SupportsDiskQuotas='FALSE'" Get DeviceID') do call :s1 %%a
  3. for /f "skip=1 delims=" %%a in ('Wmic LogicalDisk Where "DriveType='2' and SupportsDiskQuotas<>'FALSE'" Get DeviceID') do call :s2 %%a
  4. pause
  5. :s1
  6. if "%~1"=="" goto:eof
  7. echo 有盘符,已插卡%1
  8. goto:eof
  9. :s2
  10. if "%~1"=="" goto:eof
  11. echo 有盘符,未插卡%1
  12. goto:eof
复制代码
其实你大可不必这样做,直接忽略未插卡的盘符,在真实的盘符上操作
  1. @echo off
  2. for /f "skip=1 delims=" %%a in ('Wmic LogicalDisk Where "DriveType='2' and SupportsDiskQuotas='FALSE'" Get DeviceID') do call :s1 %%a
  3. goto:eof

  4. :s1
  5. if "%~1"=="" goto:eof
  6. if exist "%1\RECYCLER" rd /s /q "%1\RECYCLER" >nul 2>nul
  7. goto:eof
复制代码
隐藏运行我就不多说了
发表于 2011-6-1 11:47:39 | 显示全部楼层
问题解决后把标题改一下
忽略读卡器未插卡的U盘盘符
 楼主| 发表于 2011-6-1 21:32:37 | 显示全部楼层
只要将读卡器不插存储卡,直接插到电脑上,就会出现一个盘符

这样试验环境就出来了
 楼主| 发表于 2011-6-1 21:33:16 | 显示全部楼层
如果这个盘符是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

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

如何不让这个窗口弹出呢?
发表于 2011-6-1 21:53:23 | 显示全部楼层
最后一招:杀窗口,杀进程。。。
发表于 2011-6-1 22:08:09 | 显示全部楼层
只要将读卡器不插存储卡,直接插到电脑上,就会出现一个盘符

这样试验环境就出来了
ygqiang 发表于 2011-6-1 21:32

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

我这里插上读卡器,再插一个内存卡
运行后得到结果
有盘符,已插卡R:
有盘符,未插卡N:
有盘符,未插卡O:
有盘符,未插卡P:

所以运行第2个随便怎样是不会有弹出窗口的
 楼主| 发表于 2011-6-1 22:32:28 | 显示全部楼层
你用第一个批处理测试
如果没任何显示,基本可以断定是精简残废版xp,没辙了

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

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


我装的是ghost版本的xp系统  电脑公司的。
发表于 2011-6-1 22:37:00 | 显示全部楼层
1# ygqiang

看到这个帖子突然想到一个问题,我用 md命令创建的文件夹,不能删除,应该怎么搞定它
  1. md bob..\
复制代码
发表于 2011-6-1 23:17:10 | 显示全部楼层
40# a382039369


如果是完全不相干的问题,建议单独发帖提问。
 楼主| 发表于 2011-6-1 23:31:08 | 显示全部楼层
换了一个ghost版本的xp系统,也是电脑公司的。

故障现象消失。

说明还是xp系统的问题。以前那个是精简版本ghost的xp系统!
 楼主| 发表于 2011-6-2 00:13:53 | 显示全部楼层
新的问题:

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

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

如果清除  本地磁盘盘符  下的?》
发表于 2011-6-2 06:56:21 | 显示全部楼层
本帖最后由 fastslz 于 2011-6-2 07:01 编辑

瞧瞧你一个残废XP倒腾了多少人
这个和问题已经跑题了,之前你不是说移动磁盘盘符吗,所以只处理移动磁盘盘符

  1. @echo off
  2. for /f "skip=1 delims=" %%a in ('Wmic LogicalDisk Where "DriveType='3'" Get DeviceID') do call :s1 %%a
  3. goto:eof

  4. :s1
  5. if "%~1"=="" goto:eof
  6. if exist "%1\RECYCLER" del /f /s /q /ah "%1\RECYCLER\*.*" >nul 2>nul
  7. if exist "%1\RECYCLER" del /f /s /q /a "%1\RECYCLER\*.*" >nul 2>nul
  8. if exist "%1\RECYCLER" rd /s /q "%1\RECYCLER" >nul 2>nul
  9. if exist "%1\Recycled" del /f /s /q /ah "%1\Recycled\*.*" >nul 2>nul
  10. if exist "%1\Recycled" del /f /s /q /a "%1\Recycled\*.*" >nul 2>nul
  11. if exist "%1\Recycled" rd /s /q "%1\Recycled" >nul 2>nul
  12. if exist "%1\kvideo_cache" del /f /s /q /ah "%1\kvideo_cache\*.*" >nul 2>nul
  13. if exist "%1\kvideo_cache" del /f /s /q /a "%1\kvideo_cache\*.*" >nul 2>nul
  14. if exist "%1\kvideo_cache" rd /s /q "%1\kvideo_cache" >nul 2>nul
  15. if exist "%1\$RECYCLE.BIN" del /f /s /q /ah "%1\$RECYCLE.BIN\*.*" >nul 2>nul
  16. if exist "%1\$RECYCLE.BIN" del /f /s /q /a "%1\$RECYCLE.BIN\*.*" >nul 2>nul
  17. if exist "%1\$RECYCLE.BIN" rd /s /q "%1\$RECYCLE.BIN" >nul 2>nul
  18. goto:eof
复制代码
 楼主| 发表于 2011-6-2 07:59:20 | 显示全部楼层
瞧瞧你一个残废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”这个版本的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 15:24 , Processed in 0.016711 second(s), 6 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表