A recent MDT project a client was using USB media to do the builds. This is easy enough to accomplish but something they couldn’t handle was during the build, the USB drive gets assigned D and devices with optical drives ended up with E and so forth…
This wasn’t acceptable for various reasons in their environment so we had to force the USB builds to assign an appropriate drive letter.
A quick search lead me here which confirmed the point of the sequence I needed to modify to meet the requirement.
Essentially, we need to modify the LTIBootStrap.vbs to manage the drive letters during the first boot.
The process to execute in the LTIBootStrap:
- Change USB drive to R
- Change DVD-Rom to D
Before we do this, let’s create the two scripts to achieve our goal:
Note: another good resource for this task can be found here and here
Change USB drive to R – “Set_R.cmd”
This script creates a log file so the build engineers can do some troubleshooting if required. I personally would turn this off but the desktop admin liked having it there. They used a different variable but for sharing purposes I’ve changed it to use Windows\Temp folder
Note: This process requires the USB drive to be labelled “MDTBoot” which was already part of the existing process for these guys so it worked for me perfectly.
@echo off
cls
set MDTLogs=%systemdrive%\Windows\Temp
mkdir %MDTLogs%
echo 1. Begin management of MDTBoot USB Drive > %MDTLogs%\USBDriveLog.txt
echo. >> %MDTLogs%\USBDriveLog.txt
echo. > %MDTLogs%\ChangeDrive.tmp
echo list volume > %MDTLogs%\ListDrives.tmp
FOR /F “tokens=2-6” %%a IN (‘diskpart /s %MDTLogs%\ListDrives.tmp’) DO @IF /I “%%b” == “MDTBoot” @SET Volume=%%a
FOR /F “tokens=2-6” %%a IN (‘diskpart /s %MDTLogs%\ListDrives.tmp’) DO @IF /I “%%c” == “MDTBoot” @SET Volume=%%a
echo 2. Identify USB drives labeled ‘MDTBoot’ >> %MDTLogs%\USBDriveLog.txt
diskpart /s %MDTLogs%\ListDrives.tmp >> %MDTLogs%\USBDriveLog.txt
echo. >> %MDTLogs%\USBDriveLog.txt
IF DEFINED Volume echo select volume %Volume% >> %MDTLogs%\ChangeDrive.tmp
IF DEFINED Volume echo select volume %Volume% >> %MDTLogs%\USBDriveLog.txt
IF DEFINED Volume echo assign letter=R: >> %MDTLogs%\ChangeDrive.tmp
IF DEFINED Volume echo assign letter=R: >> %MDTLogs%\USBDriveLog.txt
IF DEFINED Volume echo. >> %MDTLogs%\USBDriveLog.txt
IF DEFINED Volume echo 3. Changed MDTBoot Removable assignment drive to R >> %MDTLogs%\USBDriveLog.txt
diskpart /s %MDTLogs%\ChangeDrive.tmp
echo. >> %MDTLogs%\USBDriveLog.txt
echo 4. Volume List post reassignment… >> %MDTLogs%\USBDriveLog.txt
diskpart /s %MDTLogs%\ListDrives.tmp >> %MDTLogs%\USBDriveLog.txt
del /q /f %MDTLogs%\ListDrives.tmp
del /q /f %MDTLogs%\ChangeDrive.tmp
echo. >> %MDTLogs%\USBDriveLog.txt
echo 5. Thank you, come again… >> %MDTLogs%\USBDriveLog.txt
exit /b 0
Change DVD-ROM to D – “Set_D.cmd”
This is essentially the same process as above but tuned to deal with the DVD-ROM drive
@echo off
cls
set MDTLogs=%systemdrive%\Windows\Temp
echo 1. Begin management of DVD Drive > %MDTLogs%\DVDDriveLog.txt
echo. >> %MDTLogs%\DVDDriveLog.txt
echo. > %MDTLogs%\ChangeDrive.tmp
echo list volume > %MDTLogs%\ListDrives.tmp
diskpart /s %MDTLogs%\ListDrives.tmp >> %MDTLogs%\DVDDriveLog.txt
echo. >> %MDTLogs%\DVDDriveLog.txt
FOR /F “tokens=2-8” %%a IN (‘diskpart /s %MDTLogs%\ListDrives.tmp’) DO @IF /I “%%b” == “DVD-ROM” @SET Volume=%%a
FOR /F “tokens=2-8” %%a IN (‘diskpart /s %MDTLogs%\ListDrives.tmp’) DO @IF /I “%%c” == “DVD-ROM” @SET Volume=%%a
FOR /F “tokens=2-8” %%a IN (‘diskpart /s %MDTLogs%\ListDrives.tmp’) DO @IF /I “%%d” == “DVD-ROM” @SET Volume=%%a
FOR /F “tokens=2-8” %%a IN (‘diskpart /s %MDTLogs%\ListDrives.tmp’) DO @IF /I “%%e” == “DVD-ROM” @SET Volume=%%a
FOR /F “tokens=2-8” %%a IN (‘diskpart /s %MDTLogs%\ListDrives.tmp’) DO @IF /I “%%f” == “DVD-ROM” @SET Volume=%%a
FOR /F “tokens=2-8” %%a IN (‘diskpart /s %MDTLogs%\ListDrives.tmp’) DO @IF /I “%%g” == “DVD-ROM” @SET Volume=%%a
FOR /F “tokens=2-8” %%a IN (‘diskpart /s %MDTLogs%\ListDrives.tmp’) DO @IF /I “%%h” == “DVD-ROM” @SET Volume=%%a
IF DEFINED Volume echo select volume %Volume% >> %MDTLogs%\ChangeDrive.tmp
IF DEFINED Volume echo select volume %Volume% >> %MDTLogs%\DVDDriveLog.txt
IF DEFINED Volume echo assign letter=D: >> %MDTLogs%\ChangeDrive.tmp
IF DEFINED Volume echo assign letter=D: >> %MDTLogs%\DVDDriveLog.txt
IF DEFINED Volume echo. >> %MDTLogs%\DVDDriveLog.txt
IF DEFINED Volume echo 3. Changed DVD-ROM assignment drive to D >> %MDTLogs%\DVDDriveLog.txt
diskpart /s %MDTLogs%\ChangeDrive.tmp
echo. >> %MDTLogs%\DVDDriveLog.txt
echo 4. Volume List post reassignment… >> %MDTLogs%\DVDDriveLog.txt
diskpart /s %MDTLogs%\ListDrives.tmp >> %MDTLogs%\DVDDriveLog.txt
del /q /f %MDTLogs%\ListDrives.tmp
del /q /f %MDTLogs%\ChangeDrive.tmp
echo. >> %MDTLogs%\DVDDriveLog.txt
echo 5. Thank you, come again… >> %MDTLogs%\DVDDriveLog.txt
exit /b 0
The LTIBootStrap.vbs
Ok, now we have our two scripts that juggle our drive letters, let’s update our LTIBootStrap.vbs to utilise these…
Immediately after the “Initialization” section (@ line 40 in LTIBootStrap in MDT2013), lets run our two scripts.
‘//—————————————————————————-
‘// Initialization
‘//—————————————————————————-
Set oShell = CreateObject(“WScript.Shell”)
Set oFSO = CreateObject(“Scripting.FileSystemObject”)
‘//—————————————————————————-
‘// Set MDT Boot drive letter to R:
‘//—————————————————————————-
oShell.run “C:\Windows\System32\Set_R.cmd”, 1, true
‘//—————————————————————————-
‘// Set DVD-ROM drive letter to D:
‘//—————————————————————————-
oShell.run “C:\Windows\System32\Set_D.cmd”, 1, true
‘//—————————————————————————-
‘// Find LiteTouch.wsf and run it
‘//—————————————————————————-
With these 3 steps, next time you do a USB media build, you can leave the media plugged in and the build will end with the removable drive as R and the DVD drive as D
Note: The LTIBootStrap.vbs call the cmd files from the C:\windows\system32 folder so the two scripts need to be available in that location. I use the \\DeploymentShare$\$OEM$\$$\System32 folder in the deployment share utilized during the Copy OEM Files step.
On the builds, you will end up with two log files providing help for the build engineers to troubleshoot any drive assignment anomalies during this process.
Trivial, but useful…
Enjoy,
Dan
Kenny Poh
Hi Dan
Thanks! i am having this problem too!
i am using the MDT workbench.
Just to check
in my offline MDT usb stick or deployment share, the $OEM$ is empty., do i just create the path manually and place the two .cmd inside ?
Kenny Poh
i have a error on the line “FOR /F “tokens=2-6” –> 2-6 unexpected
Kenny Poh
at which step in the MDT task sequence do you call for LTIBootStrap.vbs ?