Page 1 of 1
Command line utility
Posted: Tue Jan 13, 2026 9:41 pm
by ben
Hi Alex,
I try to create a program wich automatically create a backup (bytes by bytes) of an USB key in my computer (without use the ide application).
I have seen in the 1.23 version, you have add the command line utility (I'm now on the 1.91).
I've see the helper, but I don't understand how to use the command with the different arguments (mode, device and file).
Have you an example to show me how to use the command line.
I hope my request are understandable
Best regards,
Ben
Re: Command line utility
Posted: Tue Jan 13, 2026 11:23 pm
by Alex
Hi,
First of all thanks for your interest in USB Image Tool. To automate a backup with the command line utility, you first need to figure out device information.
The list command gives you a list of connected USB mass storage devices. In special cases (USB HDDs or flash drives reporting as such) you need to to add the /n option. The output should be like this.
Code: Select all
X:\Versions\USB Image Tool\191>usbitcmd l
USB Image Tool 1.91
COPYRIGHT 2006-2025 Alexander Beug
https://www.alexpage.de
Device | P# | Friendly Name | V# | Volume Name | Path | Size
------------------------------------------------------------------------------
3 | 2 | Forza Motorsport 3 USB D | 1 | FORZA | F:\ | 1905 MB
The relevant number is the one in the P# column. This is the device physical drive number. You need this for calling the backup command.
The backup can be called by the following command.
Code: Select all
X:\Versions\USB Image Tool\191>usbitcmd b 2 d:\forza.img /p
USB Image Tool 1.91
COPYRIGHT 2006-2025 Alexander Beug
https://www.alexpage.de
Creating backup for "Forza Motorsport 3 USB Device" (F:\)...ok
b is for backup mode. 2 is the identifying mumber. d:\forza.\img is the file (including path) where the image file is created. /p option tells the tool to interpret the given number as the physical drive number (instead of the device id). Please check the general usage that is shown when just calling usbitcmd for further options (compression, block size, scrollable output, ...).
Two important hints:
- Both device and physical number are not guaranteed to be the same after rebooting, unplugging or plugging in devices. Writing a batch file based on a previous call of usbitcmd l and its listed numbers is not guaranteed to work the next time. Numbers (device and physical) can change and over the last Windows versions Microsoft also changed the behavior of how the numbers are assigned to the devices (the device number was relative unique and constant on the same PC for Windows XP, but this changed at least with Windows 7). If you plan to automate things, you have to implement some logic to get the correct device or physical number from the usbit l output. There is no way to identify a device for backup or restore other than the numbers at the moment. This would have to be added with future versions of USB Image Tool.
- Please see and respect the USB Image Tool license if you plan to publish your program.
Re: Command line utility
Posted: Tue Jan 13, 2026 11:44 pm
by ben
thanks a lot for the response.
I work on a program who look the serial number of the USB Disk by the "Get-CimInstance Win32_DiskDrive" command on power shell,
so I can found the P# number use for the backup command.
Perfect !!
The sub-key that I didn't know will cannot copy, I check serial number of each key introduce in the computer.
After I begin the backup.
What represent the '/p' in the command ?
Don't worry about the license it's only for myself (just a random night idea

)
Ben
Re: Command line utility
Posted: Wed Jan 14, 2026 6:37 pm
by Alex
/p tells the tool to use the physical drive number (P# column) instead of the device id (Device column) to identify the device to use for backup/restore. When I started with USB Image Tool (2006 on Windows XP) this was the best identifier for a plugged in device, because it did usually not change even when plugged/unplugged. This changed with either Vista or Win7, so I added the physical drive number as another option. The P# should match with the Device ID from the following command.
Code: Select all
PS C:\Users\alex> Get-CimInstance Win32_DiskDrive
DeviceID Caption Partitions Size Model
-------- ------- ---------- ---- -----
\\.\PHYSICALDRIVE3 Generic STORAGE DEVICE USB Device 0 Generic STORAGE DEVICE USB Device
\\.\PHYSICALDRIVE5 Generic STORAGE DEVICE USB Device 0 Generic STORAGE DEVICE USB Device
\\.\PHYSICALDRIVE2 Generic STORAGE DEVICE USB Device 0 Generic STORAGE DEVICE USB Device
\\.\PHYSICALDRIVE0 KINGSTON SKC3000D2048G 4 2048407280640 KINGSTON SKC3000D2048G
\\.\PHYSICALDRIVE4 Generic STORAGE DEVICE USB Device 1 63861073920 Generic STORAGE DEVICE USB Device
\\.\PHYSICALDRIVE1 KINGSTON SKC3000D2048G 2 2048407280640 KINGSTON SKC3000D2048G
Code: Select all
PS X:\versions\USB Image Tool\191> ./usbitcmd l
USB Image Tool 1.91
COPYRIGHT 2006-2025 Alexander Beug
https://www.alexpage.de
Device | P# | Friendly Name | V# | Volume Name | Path | Size
------------------------------------------------------------------------------
5 | 4 | Generic STORAGE DEVICE U | 1 | ROMS | J:\ | 60899 MB