Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect the drive letter of a booted USB drive from script?

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.

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?

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#

like image 936
Doug Chase Avatar asked Apr 06 '09 14:04

Doug Chase


1 Answers

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

Don't know if that helps at all.

like image 100
Tester101 Avatar answered Sep 25 '22 16:09

Tester101