5

我从可引导的 UFD 启动 WinPE 2,我需要检测驱动器号以便告诉 ImageX 在哪里可以找到 WIM。但是,根据我正在成像的机器,有不同的安装驱动器。

我需要一种方法来始终将 UFD 安装在 P: 或其他位置。有没有办法检测机器启动的驱动器的盘符,或者有另一种方法可以将我的 WIM 文件的位置传递给可从 startnet.cmd 访问的变量?

这是 TechNet 上遇到相同问题的其他人。

http://social.technet.microsoft.com/Forums/en-US/itprovistadeployment/thread/3e8bb8db-a1c6-40be-b4b0-58093f4833be?prof=required#

4

4 回答 4

3

此 VBScript 将为每个可移动驱动器显示一条消息(字母:描述),可以轻松修改以搜索特定驱动器并返回该字母。

 
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colDisks = objWMIService.ExecQuery("Select * from Win32_LogicalDisk where MediaType = 11")

For Each objDisk in colDisks
    Wscript.Echo objDisk.DeviceID & objDisk.Description
Next

不知道这是否有帮助。

于 2009-04-06T20:28:53.310 回答
3

与此处提到的其他解决方案相比,它是一个不太通用的解决方案,但似乎有一种特定的方法可以确定从哪个底层卷启动“RAM 驱动器启动”的 Windows PE 操作系统。从Windows 自动安装工具包中有关 Windows PE 的文档中:

如果您没有启动 Windows 部署服务,确定 Windows PE 从何处启动的最佳方法是首先检查 PEBootRamdiskSourceDrive 注册表项。如果不存在,请扫描正确 PEBootType 的驱动器并查找某种标识引导驱动器的标记文件。

(有问题的注册表值位于 HKLM\SYSTEM\CurrentControlSet\Control 下。)

于 2009-04-17T08:30:20.797 回答
0

这是一个非最佳解决方案。在这种情况下,UFD 必须有一个特定的名称,该名称将传递给脚本,该脚本搜索每个可能的驱动器号以查找匹配项。依靠同名的闪存驱动器可能不切实际。

仍然希望有人能提供更好的答案!

setlocal

:: Initial variables
set TMPFILE=%~dp0getdrive.tmp
set driveletters=abcdefghijklmnopqrstuvwxyz
set MatchLabel_res=

for /L %%g in (2,1,25) do call :MatchLabel %%g %*

if not "%MatchLabel_res%"=="" echo %MatchLabel_res%

goto :END

:: Function to match a label with a drive letter. 
::
:: The first parameter is an integer from 1..26 that needs to be 
:: converted in a letter. It is easier looping on a number
:: than looping on letters.
::
:: The second parameter is the volume name passed-on to the script
:MatchLabel

:: result already found, just do nothing 
:: (necessary because there is no break for for loops)
if not "%MatchLabel_res%"=="" goto :eof

:: get the proper drive letter
call set dl=%%driveletters:~%1,1%%

:: strip-off the " in the volume name to be able to add them again further
set volname=%2
set volname=%volname:"=%

:: get the volume information on that disk
vol %dl%: > "%TMPFILE%" 2>&1

:: Drive/Volume does not exist, just quit
if not "%ERRORLEVEL%"=="0" goto :eof

set found=0
for /F "usebackq tokens=3 delims=:" %%g in (`find /C /I "%volname%" "%TMPFILE%"`) do set found=%%g

:: trick to stip any whitespaces
set /A found=%found% + 0


if not "%found%"=="0" set MatchLabel_res=%dl%:
goto :eof

:END

if exist "%TMPFILE%" del "%TMPFILE%"
endlocal
于 2009-04-06T18:16:34.737 回答
0

为了更详细地阐述鲁本的答案,这是我的批处理文件:

wpeutil UpdateBootInfo
for /f "usebackq skip=1 tokens=3 delims= " %%l in ( `reg query HKLM\System\CurrentControlSet\Control /v PEBootRAMDiskSourceDrive` ) do set "PendrivePath=%%l"
set "PendriveLetter=%PendrivePath:~0,1%"
echo The boot pendrive's drive letter is %PendriveLetter%
于 2021-06-22T09:30:31.680 回答