联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
@echo off fsutil >nul 2>nul if "%errorlevel%"=="1" echo 非管理员身份运行&ping/n 5 127.1>nul&exit if "%errorlevel%"=="9009" echo 运行环境必须是 Windows XP Professional 以上系统&ping/n 5 127.1>nul&exit for /f "skip=2 tokens=2,3 delims=," %%i in ('WMIC LogicalDisk Where "DriveType=2 and SupportsDiskQuotas=FALSE" Get DeviceID^,FreeSpace /format:csv 2^>nul') do call :xxx %%i %%j if not defined freesize echo 未找到可移动磁盘 pause&exit :xxx set freesize=%2 if not defined freesize goto:eof if exist "%1\test.txt" del /q "%1\test.txt" echo 正在写入%freesize%字节大小的测试文件到%~1盘... fsutil file createnew "%1\test.txt" %freesize% >nul&&echo %1 盘文件拷贝测试成功!||echo %1 盘文件拷贝测试失败 del "%1\test.txt" 2>nul echo. goto:eof
Originally posted by fastslz at 2008-2-21 08:33 PM: 确定了一下那贴应该不是楼主发的,再说这段代码应用很有价值的,回复你一下了! 最后希望楼主改下标题,以便方便以后搜索 [code]@echo off for /f & ...
Originally posted by xmi at 2008-2-21 20:54: 不行, 我試過以上coding, 但都是失敗, 如下?? Q:\Documents\>rem 獲取磁盤容量 正在寫入字節大小的測試文件到Q:盤... 盤文件拷貝測試失敗 請按任意鍵繼續 . . .
C:\Documents and Settings\FastSLZ>dir /-c 驱动器 C 中的卷是 WINXP 卷的序列号是 4C4E-A0AB C:\Documents and Settings\FastSLZ 的目录 2008-02-12 20:40 <DIR> . 2008-02-12 20:40 <DIR> .. 2007-10-06 02:41 <DIR> Contacts 2007-09-26 22:57 <DIR> Favorites 2008-02-12 21:05 <DIR> Phone Browser 2007-09-27 00:25 <DIR> WINDOWS 2007-09-27 13:59 <DIR> 「开始」菜单 2008-02-21 10:59 <DIR> 桌面 0 个文件 0 字节 8 个目录 1561735168 可用字节 C:\Documents and Settings\FastSLZ>
@echo off for /f "skip=1 delims= " %%a in ('"Wmic LogicalDisk Where DriveType="2" Get DeviceID|find /v "A:""') do call :xxx "%%a" pause :xxx if "%~1"=="" goto:eof if exist "%~1\test.txt" del /q "%~1\test.txt" for /f "tokens=3" %%b in ('dir/-c "%~1\"^|find "位元組可用"') do set freesize=%%b echo 正在写入%freesize%字节大小的测试文件到%~1盘... fsutil file createnew "%~1\test.txt" %freesize% >nul&&echo %~1 盘文件拷贝测试成功!||echo 盘文件拷贝测试失败 del "%~1\test.txt" 2>nul echo. goto:eof
Originally posted by beyond18wu at 2008-2-22 11:06: 感谢大家的回答,我试了下,上面代码能获取本地磁盘的容量,但移动磁盘容量获取不到是怎么回事