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

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

[复制链接]
发表于 2011-5-30 15:50:11 | 显示全部楼层 |阅读模式
rd /s /q "f:\RECYCLER" >nul 2>nul

xp系统下运行这个命令,

1、如果f盘符不存在,不会弹出信息菜单

2、如果f盘符光驱,也不会弹出信息菜单

3、如果f盘符是笔记本的读卡器,里面也没有插存储卡的话,会弹出一个没有找到软驱的类似菜单。

每次都只有点“继续”按钮,才能运行。

这种情况,如何让这个命令后台静默运行?而不弹出这种菜单?

基本确定是xp系统的问题。
使用精简版本的电脑公司xp ghost系统,出现的怪问题。

更新:运行下面这个bat批处理文件(目的是删除 我的电脑 里面 所有盘下面的指定目录)。

好像已经不弹出窗口了。
  1. for /f "skip=1 delims=" %%a in ('Wmic LogicalDisk Where "DriveType='2' and SupportsDiskQuotas='FALSE'" Get DeviceID') do call :s1 %%a


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




  3. :s1

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

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

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

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

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

  17. goto:eof
复制代码

评分

参与人数 1PB +2 收起 理由
zm900612 + 2 感谢给帖子标题标注[已解决]字样

查看全部评分

发表于 2011-5-30 15:55:20 | 显示全部楼层
没碰到过,不过也许可以这样?
  1. if exist "f:\RECYCLER\nul" rd /s /q "f:\RECYCLER" >nul 2>nul
复制代码
发表于 2011-5-30 16:10:20 | 显示全部楼层
本帖最后由 batman 于 2011-5-30 16:20 编辑

还是调用vbs来隐藏运行吧:

  1. @echo off
  2. mshta vbscript:createobject("wscript.shell").run("cmd /c rd /s /q f:\RECYCLER",0)(window.close)
复制代码
 楼主| 发表于 2011-5-30 16:13:18 | 显示全部楼层
我已经可以通过vbs文件,调用bat文件实现后台静默运行。

一般的bat文件,都能实现后台运行。

就这个命令,不能实现。
 楼主| 发表于 2011-5-30 16:15:25 | 显示全部楼层
还是调用vbs来隐藏运行吧:
@echo off
mstha vbscript:createobject("wscript.shell").run("cmd/crd /s /q f:\RECYCLER",0)(window.close)

batman 发表于 2011-5-30 16:10


这个方法不行。我试验了。

一般的bat批处理命令,都是可以用这个方法的。

关键是我提到的那种情况,就不行了。
发表于 2011-5-30 16:20:37 | 显示全部楼层
5# ygqiang
刚才笔误,已修改,见笑了。。。
 楼主| 发表于 2011-5-30 16:46:35 | 显示全部楼层
if exist f: del /f /s /q /ah "f:\RECYCLER\*.*" >nul 2>nul
if exist f: del /f /s /q /a "f:\RECYCLER\*.*" >nul 2>nul

if exist f: rd /s /q "f:\RECYCLER" >nul 2>nul

用这个命令,还是不行。
 楼主| 发表于 2011-5-30 16:50:27 | 显示全部楼层
mshta vbscript:createobject("wscript.shell").run("cmd /c rd /s /q f:\RECYCLER",0)(window.close)

这个方法,也用了。

还是一样会弹出窗口啊。
发表于 2011-5-30 16:50:35 | 显示全部楼层
那就先检测盘符的类型吧
发表于 2011-5-30 16:50:56 | 显示全部楼层
“if esist f:”不行的话,
“if exist f:\RECYCLER\”也没效果吗?
那就不知道了
 楼主| 发表于 2011-5-30 16:52:55 | 显示全部楼层
那就先检测盘符的类型吧
batman 发表于 2011-5-30 16:50


这个不懂啊。什么意思?

弹出窗口的提示是:
 楼主| 发表于 2011-5-30 16:58:28 | 显示全部楼层
“if esist f:”不行的话,
“if exist f:\RECYCLER\”也没效果吗?
那就不知道了
zm900612 发表于 2011-5-30 16:50


试过了,没有效果
发表于 2011-5-30 17:16:11 | 显示全部楼层
检查盘符类型:
fsutil fsinfo drivetype f:
或者用wmic
发表于 2011-5-30 20:08:57 | 显示全部楼层
楼上说的极是啊,用命令检查后,根据返回值,决定怎么做 0,0
不知道检查的时候会弹不。。。
发表于 2011-5-30 20:41:59 | 显示全部楼层
先判断要删除的文件夹是否存在,再rd 也不行??
没道理吧。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-3-17 14:29 , Processed in 0.022664 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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