|
axi
中级用户
   脚本爱好者
积分 238
发帖 93
注册 2007-3-11 来自 GZ
状态 离线
|
『楼 主』:
[已结]如何用批处理检测到硬盘中的分区数量。
使用 LLM 解释/回答一下
制作一个在Win下做Ghost备份还原的小程序,需要检测硬盘中的分区数(插入U盘时也不影响检测结果),以便把备份文件自动存放到最后分区中,我知道用Ghost32.exe可以做到,但我想用批处理来完成应该更简单些,请问如何做到?
Last edited by axi on 2007-3-20 at 09:17 PM ]
Make a small program to do Ghost backup and restore under Win, which needs to detect the number of partitions in the hard disk (when a USB flash drive is inserted, it does not affect the detection result), so that the backup file can be automatically stored in the last partition. I know it can be done with Ghost32.exe, but I think it should be simpler to do it with batch processing. How to do it?
Last edited by axi on 2007-3-20 at 09:17 PM ]
|
|
2007-3-12 03:37 |
|
|
htysm
高级用户
   
积分 866
发帖 415
注册 2005-12-4
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
@echo off
set num=
for %%i in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
fsutil fsinfo drivetype %%i: | find /i "固定" >nul 2>nul && set /a num+=1
)
echo 本地磁盘分区有 %num% 个。
pause>nul
@echo off
set num=
for %%i in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
fsutil fsinfo drivetype %%i: | find /i "Fixed" >nul 2>nul && set /a num+=1
)
echo There are %num% local disk partitions.
pause>nul
|
|
2007-3-12 05:19 |
|
|
qingfushuan
高级用户
   
积分 502
发帖 327
注册 2006-12-30
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
试试这个
@echo off
setlocal enabledelayedexpansion
for /f "skip=1 tokens=1,2 delims=\" %%a in ('fsutil fsinfo drives^|find /v ""') do (
set aa=%%a
set aa=!aa:~-2!
for /f "tokens=1 " %%i in ('fsutil fsinfo drivetype !aa! ^|find "固定"') do @echo %%i
)
pause
Try this
@echo off
setlocal enabledelayedexpansion
for /f "skip=1 tokens=1,2 delims=\" %%a in ('fsutil fsinfo drives^|find /v ""') do (
set aa=%%a
set aa=!aa:~-2!
for /f "tokens=1 " %%i in ('fsutil fsinfo drivetype !aa! ^|find "Fixed"') do @echo %%i
)
pause
|
|
2007-3-12 05:38 |
|
|
axi
中级用户
   脚本爱好者
积分 238
发帖 93
注册 2007-3-11 来自 GZ
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
htysm 的方法是可以,但插入U盘后检多了一个分区,请问如何解决呢?
The method of htysm is okay, but after inserting the USB flash drive, an extra partition is detected. How to solve this?
|
|
2007-3-12 10:31 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
Wmic LogicalDisk get caption,description,freespace
Wmic LogicalDisk get caption,description,freespace
|
|
2007-3-12 10:32 |
|
|
axi
中级用户
   脚本爱好者
积分 238
发帖 93
注册 2007-3-11 来自 GZ
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
qingfushuan 的方法是获取各分区盘符,但也把U盘也列出,也请问有无方法解决?
The method of qingfushuan is to obtain the drive letters of each partition, but it also lists the USB flash drive. Also, is there a way to solve this?
|
|
2007-3-12 10:35 |
|
|
ww111222
中级用户
  
积分 354
发帖 83
注册 2003-3-23
状态 离线
|
|
2007-3-12 12:31 |
|
|
0451lym
高级用户
   
积分 760
发帖 357
注册 2005-10-10
状态 离线
|
|
2007-3-12 13:21 |
|
|
llztt1
中级用户
  
积分 214
发帖 94
注册 2007-1-11
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
有个drvtypes会显示所有现有盘符,及相关信息,批处理判断其信息,可以把U盘A、B、内存盘、各种光驱盘剔掉。。
There is a drvtypes that will display all existing drive letters and related information. Batch processing can judge the information and exclude USB drives A, B, RAM disks, and various optical drive disks.
|
|
2007-3-12 21:34 |
|
|
htysm
高级用户
   
积分 866
发帖 415
注册 2005-12-4
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
2楼的代码不会显示U盘的.除非你是移动硬盘.
The code on the 2nd floor won't display the USB flash drive. Unless it's a mobile hard drive.
|
|
2007-3-12 22:51 |
|
|
qingfushuan
高级用户
   
积分 502
发帖 327
注册 2006-12-30
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
Originally posted by axi at 2007-3-11 09:35 PM:
qingfushuan 的方法是获取各分区盘符,但也把U盘也列出,也请问有无方法解决?
『第 13 楼』:
试试下面的可以吗?
@echo off
setlocal enabledelayedexpansion
for /f "skip=1 tokens=1,2 delims=\" %%a in ('fsutil fsinfo drives^|find /v ""') do (
set aa=%%a
set aa=!aa:~-2!
for /f "tokens=1 " %%i in ('fsutil fsinfo drivetype !aa! ^|findstr /i "固定 移动"') do @echo %%i
)
pause
Originally posted by axi at 2007-3-11 09:35 PM:
The method of qingfushuan is to obtain the drive letters of each partition, but it also lists the USB flash drive. Also, is there a way to solve this?
『13th floor』:
Can the following be tried?
@echo off
setlocal enabledelayedexpansion
for /f "skip=1 tokens=1,2 delims=\" %%a in ('fsutil fsinfo drives^|find /v ""') do (
set aa=%%a
set aa=!aa:~-2!
for /f "tokens=1 " %%i in ('fsutil fsinfo drivetype !aa! ^|findstr /i "fixed removable"') do @echo %%i
)
pause
|
|
2007-3-13 01:00 |
|
|
oilio
高级用户
    前进者
积分 641
发帖 303
注册 2007-1-10
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
wmic logicaldisk where(drivetype='3') get caption
wmic logicaldisk where(drivetype='3') get caption
|

我相信总有一天,总会遇到一个人可以相濡以沫、相吻以湿! |
|
2007-3-13 01:25 |
|
|
axi
中级用户
   脚本爱好者
积分 238
发帖 93
注册 2007-3-11 来自 GZ
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
13 楼的方法试过,还是不行,我的u盘是被视作移动硬盘。
The method on floor 13 has been tried, but it still doesn't work. My USB flash drive is regarded as a mobile hard disk.
|
|
2007-3-13 01:48 |
|