Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am creating a custom boot disk for work using Windows PE 3.0. I need to be able to tell what drive the system was booted from. it may be a CD, or a USB Flash drive. In the past, I have looked for a file on the root of the drive that holds some of our custom configuration. however that is getting a bit messy.

Basically, in addition to Windows PE, the drive or disk also has other scripts and tools. I need to remount that USB drive or DVD to the U:\ Drive, to keep thing consistent.

Basically,

Diskpart.exe
Select Volume $X
assign Letter=U
Exit

I just need to figure out how to determine that nasty little $X.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

In my debate of whether this belonged here or StackOverflow, I found an excellent answer on StackOverflow (that was never marked as being the answer, but it works perfectly for me!

Right now, I scan a bunch of drive letters, looking or a config file, this will shorten the code drastically! Basically, query the registry in PE for HKLM\SYSTEM\CurrentControlSet\Control\PERamDiskSourceDrive

I figured I'd answer it all here as well, so others scouring the internet can find it better..

Edit: for those searching for the same thing, I added this to my startnet.cmd in windows\system32 in windows PE:

REM Get Boot Drive from WinPE Registry
for /f "tokens=2,*" %%a in ('reg query HKLM\system\currentcontrolset\control /v PEBootRamDiskSourceDrive ^| find /i "PEBootRamDiskSourceDrive"') do set driveLtr=%%b 
REM Setup text file on ram drive to pass to diskpart commands
SET MountScript=X:\MountScript.TXT
ECHO SELECT VOLUME %driveLtr% > %MountSCRIPT%
ECHO assign letter=U noerr >> %MountSCRIPT%
DISKPART /S %MountSCRIPT%
REM Don't really need to cleanup, since its a ramdisk, but trying to be nice
DEL %MountSCRIPT%
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.