如何从脚本检测引导的USB驱动器盘符? [英] How can I detect the drive letter of a booted USB drive from script?

查看:153
本文介绍了如何从脚本检测引导的USB驱动器盘符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从可启动的UFD启动WinPE 2,我需要检测驱动器盘符,以便告诉ImageX在哪里可以找到WIM。然而,根据我在成像的机器,有不同的安装驱动器。

I'm launching WinPE 2 from a bootable UFD, and I need to detect the drive letter in order to tell ImageX where to find the WIM. However, depending on the machine I'm imaging, there are different mounted drives.

我需要一种方式来一直挂载UFD,比如P:或某事。有没有办法检测机器启动的驱动器的信件,或者另一种将WIM文件的位置传递到可从startnet.cmd访问的变量的方法?

I need a way to consistently mount the UFD at, say, P: or something. Is there a way to detect the letter of the drive from which the machine was booted, or another way to pass the location of my WIM file to a variable accessible from startnet.cmd?

这里是与TechNet相同问题的其他人。

Here's someone else with the same issue over at TechNet.

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

推荐答案

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

This VBScript will show a message for each removable drive (letter:description), could be easily modified to search for a particular drive and return the letter.

 
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

不知道是否有帮助。

这篇关于如何从脚本检测引导的USB驱动器盘符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆