bjay2008xmy 发表于 2024-4-12 14:52:22

softwarezheng 发表于 2024-4-12 14:58:01

谢谢

ZYYDS-FT798 发表于 2024-4-12 15:45:40

感谢分享!

yc2428 发表于 2024-4-12 16:32:27


谢谢分享

wang1126 发表于 2024-4-12 16:47:55

感谢分享

fuldho 发表于 2024-4-12 17:14:43

@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

yyz2191958 发表于 2024-4-12 18:05:39

谢谢分享

crtrccrtt 发表于 2024-4-12 18:57:45

@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

2012飘水 发表于 2024-4-12 19:10:16

虽然看不很明白,但是还得感谢分享

conlin888 发表于 2024-4-12 19:13:47

这样的方法没有普遍意义

austere 发表于 2024-4-12 19:29:45

6楼8楼的也不错,但是移动硬盘不显示可移动那就不通用了~~

bjay2008xmy 发表于 2024-4-12 20:45:27

in9 发表于 2024-4-13 00:06:41

谢谢分享!

dos时代菜鸟 发表于 2024-4-13 07:08:43







bjay2008xmy 发表于 2024-4-13 20:25:50

dos时代菜鸟 发表于 2024-4-13 23:43:07

bjay2008xmy 发表于 2024-4-13 20:25
没见过这软件,你自己写的吗

就是 pecmd 内嵌了一个 脚本。

pda8888 发表于 2024-4-15 18:03:26

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-15 23:12:11

本帖最后由 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:20:23

本帖最后由 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:35

bjay2008xmy 发表于 2024-4-16 13:29:22

撸可撸可 发表于 2024-4-16 21:10:00

啥情况?

fuyechun 发表于 4 天前

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
拉到底就可以看到了

softwarezheng 发表于 前天 09:09

感谢

chenmengen 发表于 昨天 18:19

感谢
页: [1]
查看完整版本: 批处理确定U盘盘符的方法,而不使用PECMD加载ChangeUSB.INI强制更改