どのように私は、スクリプトから起動USBドライブのドライブ文字を検出することができますか?
-
05-09-2019 - |
質問
私は、起動可能なUFDからのWinPE 2を起動しています、と私はWIMを見つけるためにImageXを伝えるために、ドライブ文字を検出する必要があります。しかし、私はイメージングてるマシンに応じて、異なるドライブをマウントがあります。
か何か:私は一貫してP、たとえば、でUFDをマウントする方法が必要です。 STARTNET.CMDから変数にアクセス可能に私のWIMファイルの場所を渡すために、マシンがブートされたドライブ、または別の方法の手紙を検出する方法はありますか?
ここでのTechNetで同じ問題をめぐる持つ他の誰かがいます。
<のhref = "http://social.technet.microsoft.com/Forums/en-US/itprovistadeployment/thread/3e8bb8db-a1c6-40be-b4b0-58093f4833be?prof=required#" のrel = "nofollowをnoreferrer 「> http://social.technet.microsoft.com/Forums/en-US/itprovistadeployment/thread/3e8bb8db-a1c6-40be-b4b0-58093f4833be?prof=required# の
解決
この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
それがすべてで助けているかどうかを知るしないでください。
他のヒント
これは、他の人がここで言及したよりも一般的な解決策だが、根本的なボリュームは、「RAMドライブ・ブート」を決定するための具体的な方法があるように見えるのWindows PE OSは以下からブートされました。 Windows拡張インストールキットでます:
は、Windowsを起動していない場合 展開サービスへの最善の方法 WindowsのPEからブートする場所を決定 最初に確認することです PEBootRamdiskSourceDriveレジストリキー。 それが存在しない場合は、ドライブをスキャンします 正しいPEBootTypeのと探し 識別するタグファイルのいくつかの種類 ブートドライブます。
(問題のレジストリ値は、HKLM \ SYSTEM \ CURRENTCONTROLSET \コントロールの下に位置しています。)
ここで非最適なソリューションです。この場合、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