谢谢分享 感谢分享 @echo off
for /f "tokens=2 delims==" %%a in ('wmic LogicalDisk where "DriveType='2'" get DeviceID /value') do (
set DriveU=%%a
)
echo.%DriveU%
pause
@echo off
for %%a 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 (
for /f %%h in ('fsutil fsinfo drivetype %%a:^|findstr "Removable.* 可移动"') do (
set DriveU=%%h
)
)
echo.%DriveU%
pause 谢谢分享 @echo off
echo,
echo 批处理确定U盘盘符
echo,
echo,
for /f "tokens=2 delims==" %%a in ('wmic LogicalDisk where "DriveType='2'" get DeviceID /value') do (
echo,
set DriveU=%%a
echo 已确定U盘盘符:%%a
)
echo,
echo,
pause
echo,
echo,
@echo off
for %%a 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 (
for /f %%h in ('fsutil fsinfo drivetype %%a:^|findstr "Removable.* 可移动"') do (
echo,
set DriveU=%%h
echo 已确定U盘盘符:%%h
)
)
echo,
echo,
echo,
pause
goto :EOF
虽然看不很明白,但是还得感谢分享 这样的方法没有普遍意义 6楼8楼的也不错,但是移动硬盘不显示可移动那就不通用了~~ 谢谢分享!
bjay2008xmy 发表于 2024-4-13 20:25
没见过这软件,你自己写的吗
就是 pecmd 内嵌了一个 脚本。 fuldho 发表于 2024-4-12 17:14
@echo off
for /f "tokens=2 delims==" %%a in ('wmic LogicalDisk where "DriveType='2'" get DeviceID...
PE下要用wmic是比较困难的。 本帖最后由 pda8888 于 2024-4-16 08:35 编辑
@echo off & setlocal enabledelayedexpansion
mode con cp select=437 > nul& rem 这样可以不清屏就切换页代码,采用英文输出信息保持一致性。
set /a "idx=0"
for /f "tokens=2,3 delims= " %%a in ('echo list volume^|diskpart^|findstr /i /r /c:"^[ ]*Volume * "') do (
REM echo list volume|diskpart|findstr /i /r /c:"^[ ]*Volume * "
REM Volume 0 C label h: NTFS Partition 952 GBHealthy Boot
REM Volume 2 D Win 11 Pro NTFS Partition 150 GBHealthy
REM Volume 3 E NTFS Partition 314 GBHealthy
REM Volume 5 U Ventoy_JameNTFS Partition 931 GBHealthy
call :is_usb %%a && (
set /a "idx+=1"
set "usb[!idx!]=%%b"
)
)
mode con cp select=936 > nul & rem 回到中文
if %idx% geq 1 (
echo USB 驱动器列表:
for /l %%u in (1 1 %idx%) do echo !usb[%%u]!:\
) else echo 没有发现 USB 驱动器
exit /b
:is_usb
REM DISKPART> sele volu 5
REM Volume 5 is the selected volume.
REM DISKPART> detail disk
REM WDS100T1 X0E-00AFY0 SCSI Disk Device
REM Disk ID: 93DFC635
REM Type : USB
REM Status : Online
REM Path : 0
REM Target : 0
REM LUN ID : 0
REM Location Path : UNAVAILABLE
REM Current Read-only State : No
REM Read-only: No
REM Boot Disk: No
REM Pagefile Disk: No
REM Hibernation File Disk: No
REM Crashdump Disk: No
REM Clustered Disk: No
REM Volume ###LtrLabel Fs Type Size Status Info
REM ---------------------------------------------------------------
REM * Volume 5 U Ventoy_JameNTFS Partition 931 GBHealthy
if "%~1"=="" exit /b 1
set "volume=%~1"
for /f "tokens=2* delims=: " %%u in ('^(echo select volume %volume% ^& echo detail disk^)^| diskpart ^| findstr /r /i /c:"^Type[ ]*:[ ]*"') do (
if /i "%%u"=="USB" (
exit /b 0
) else (
exit /b 1
)
)
exit /b 本帖最后由 fuyechun 于 2024-4-16 10:21 编辑
以前在网上搜的,在PE下能用,一直用到现在,代码也简洁。应该是没什么问题吧
@echo off
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 (
for /f %%h in ('fsutil fsinfo drivetype %%i:^|find "可移动"') do (
set DriveU=%%h
)
)
echo,%DriveU% 啥情况? bjay2008xmy 发表于 2024-4-16 13:23
**** 作者被禁止或删除 内容自动屏蔽 ****
这是微软官方的脚本,没去试过,不知道效果怎么样:
在 Windows PE 中使用此脚本来识别包含“Images”文件夹的驱动器。
@echo Find a drive that has a folder titled Images.
@for %%a 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 @if exist %%a:\Images\ set IMAGESDRIVE=%%a
@echo The Images folder is on drive: %IMAGESDRIVE%
@dir %IMAGESDRIVE%:\Images /w
链接:https://learn.microsoft.com/zh-cn/windows-hardware/manufacture/desktop/oem-deployment-of-windows-desktop-editions-sample-scripts?preserve-view=true&view=windows-11#image-deployment-scripts
拉到底就可以看到了 感谢 感谢
页:
[1]