• RMPartUSB FAQs



Q1. How can I use RMPartUSB in my Windows script files (e.g. .cmd or .bat files)?
A1. Most functions of RMPrepUSB are available in RMPartUSB and so can be scripted - except you will need to use XCOPY to copy files to the USB drive once it has been formatted.

Some special commands and code examples are shown below (code in bold, keywords in red bold):

RMPARTUSB LIST

RMPARTUSB v2.1.600 (c)2008-10 RM Education plc [SSi]
====================================================

*DRIVE 1 -   7.5GiB TakeMS MEM-Drive Smart USB Devi Fw=0.00 H:
 DRIVE 2 -   7.5GiB Verbatim STORE N GO USB Device  Fw=5.00 J:


RMPARTUSB LIST ALLDRIVES

RMPARTUSB v2.1.600 (c)2008-10 RM Education plc [SSi]
====================================================

*DRIVE 0 - 232.8GiB ST3250820AS ATA Device          Fw=3.ADG Sno=202020202020202 C:
 DRIVE 1 -   7.5GiB TakeMS MEM-Drive Smart USB Devi Fw=0.00 H:
 DRIVE 2 -   7.5GiB Verbatim STORE N GO USB Device  Fw=5.00 J:


RMPARTUSB FIND > drv.cmd

example drv.cmd file produced is:

SET DRIVE=1
SET DRIVEDESC=TakeMS MEM-Drive Smart USB Device
SET DRIVESIZE=8086618112
SET DRIVELETTER=H:
SET DRIVE1DESC=TakeMS MEM-Drive Smart USB Device
SET DRIVE1SIZE=8086618112
SET DRIVE1LETTER=H:
SET DRIVE2DESC=Verbatim STORE N GO USB Device
SET DRIVE2SIZE=8011120640
SET DRIVE2LETTER=J:

(Note: DRIVE, DRIVEDESC and DRIVELETTER are used for the FIRST USB DRIVE to be found, if more than one USB drive is expected to be in the system then use the DRIVEn variables).



Example of how to use in a batch file:

RMPartUSB FIND > drv.cmd
call drv.cmd
del drv.cmd
echo Drive 1 is a %DRIVE1DESC% with a size of %DRIVE1SIZE% and a volume letter of %DRIVE1LETTER%

Or an alternative that does the same thing without needing a temporary file:

FOR /F "tokens=*" %%A IN ('RMPartUSB FIND') DO %%A
echo Drive 1 is a %DRIVE1DESC% with a size of %DRIVE1SIZE% and a volume letter of %DRIVE1LETTER%



Another example - ask user to select a USB drive and copy files to it:

RMPARTUSB LIST
set /P DD=Please enter the USB Flash drive number you want to use: 
rmpartusb DRIVE=%dd% WINPE FAT32 2PTN VOLUME=WINPE
if errorlevel 1 echo COMMAND FAILED!
if errorlevel 1 goto :EOF
rmpartusb DRIVE=%dd% GETDRV > drv1.cmd
set USBDRIVELETTER=
call drv1.cmd
del drv1.cmd
If "%USBDRIVELETTER%"="" goto :EOF
xcopy /herky C:\mysourcefiles\*.* %USBDRIVELETTER%\*.*
echo all files copied!

example drv1.cmd file produced is:
SET USBDRIVE=1
SET USBDRIVEDESC=TakeMS MEM-Drive Smart USB Device
SET USBDRIVESIZE=8086618112
SET USBDRIVELETTER=H:



Another example - ask user to select the USB drive, partition and format the drive, add grub4dos and copy files to it:

@echo off
REM change to our working folder
pushd "C:\Program Files (x86)\RMPrepUSB"
REM list all USB drives so user can see them and their drive number
RMPARTUSB LIST
REM Ask user for a drive number
set /P DD=Please enter the USB Flash drive number you want to use: 
REM execute RMPARTUSB (insert SURE if you don't want the user prompt)
RMPARTUSB DRIVE=%dd% MSDOS FAT32 2PTN FORCELBA VOLUME=WINPE
if errorlevel 1 echo RMPARTUSB COMMAND FAILED!
if errorlevel 1 goto :EOF
set USBDRIVELETTER=
REM get the drive letter of the newly formatted drive
FOR /F "tokens=*" %%A IN ('RMPARTUSB DRIVE^=%dd% GETDRV') DO %%A
If "%USBDRIVELETTER%"=="" goto :EOF
REM install grub4dos
grubinst -v --skip-mbr-test (hd%dd%)
If errorlevel 1 goto :EOF
REM use touchdrv to ensure MBR changes are not removed by Windows!
touchdrv %USBDRIVELETTER%
REM copy grldr file over which is needed by grub4dos
copy grldr %USBDRIVELETTER%
If errorlevel 1 goto :EOF
REM copy over boot files (assumes a menu.lst file has been added for use by grub4dos)
xcopy /herky .\mybootfiles\*.* %USBDRIVELETTER%\*.*
If errorlevel 1 goto :EOF
echo Finished - All files copied!


How to find the drive number for a given drive letter

Place the following text in a file called getdnum.cmd


@echo off
echo.
SET FIND=%1
IF "%FIND%"=="" echo ERROR - Usage: %0 [driveletter]:    (e.g. %0 H:) && goto :EOF
SET FIND=%FIND:~0,1%
SET FIND=%FIND%:
FOR /F "tokens=*" %%A IN ('RMPartUSB FIND') DO %%A
REM FOR /F "tokens=*" %%A IN ('RMPartUSB FIND ALLDRIVES') DO %%A
SET DRIVENUM=
SET DRIVESIZE=
if /i "%DRIVE1LETTER%"=="%FIND%" SET DRIVENUM=1 && SET DRIVESIZE=%DRIVE1SIZE%
if /i "%DRIVE2LETTER%"=="%FIND%" SET DRIVENUM=2 && SET DRIVESIZE=%DRIVE2SIZE%
if /i "%DRIVE3LETTER%"=="%FIND%" SET DRIVENUM=3 && SET DRIVESIZE=%DRIVE3SIZE%
if /i "%DRIVE4LETTER%"=="%FIND%" SET DRIVENUM=4 && SET DRIVESIZE=%DRIVE4SIZE%
if /i "%DRIVE5LETTER%"=="%FIND%" SET DRIVENUM=5 && SET DRIVESIZE=%DRIVE5SIZE%
if "%DRIVENUM%"=="" echo DRIVE NUMBER FOR %FIND% NOT FOUND! && goto :EOF
echo %FIND% is Drive %DRIVENUM%  Size=%DRIVESIZE%


You can use this by calling (for example)   getdnum.cmd h  or  getdnum.cmd H:  , the variable DRIVENUM will contain the physical drive number of the USB drive or be empty if it is not found. Add the ALLDRIVES parameter to the RMPartUSB FIND command if you want all drives to be listed and not just USB drives (remove the word REM from the grey line so that it will run and then add the word REM to the beginning of green the line just above it).




Q2 How can I determine the correct command for RMPartUSB?

  • Type RMPartUSB for command line usage. Typing RMPARTUSB on the command line should give some help.
  • Read the manual.
  • Use RMPrepUSB, set your options and click the Prepare Drive button and note down the command line that it uses to call RMPartUSB (uncheck 'No user prompts' checkbox).