[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  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
复制代码
隐藏运行我就不多说了

TOP

问题解决后把标题改一下
忽略读卡器未插卡的U盘盘符

TOP

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

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

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

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

所以运行第2个随便怎样是不会有弹出窗口的

TOP

本帖最后由 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
复制代码

TOP

返回列表