VirtualBox UUID Change Script

UPDATE: Oracle has decided to change the command from setvdiuuid to sethduuid for version 4 of VirtualBox. Please make this correction if you are using version 4.

How many times do you simply copy a virtual hard drive when you want to stand up a development environment? In VirtualBox, it isn’t as simple as a simple copy, paste, and rename. Each virtual hard drive in the VirtualBox world (.vdi files) gets its own universally unique identifier, or UUID. When you copy a vdi file with your file explorer it also brings over the UUID. Fortunately, VirtualBox has a command to generate a new UUID for a copied vdi file.

%ProgramFiles%\Oracle\VirtualBox\VBoxManage.exe internalcommands setvdiuuid

Being in the SharePoint development world, I create new virtual machines all the time so I created a script to take care of the UUID change. I have a batch file named changeUUID.bat that this script is contained.

IF "%1"=="" GOTO Error
"c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands setvdiuuid %1
ECHO No file path given!

Gist Link:

NOTE: VirtualBox does offer a command called clonevdi which will copy the vdi and ensure a new UUID is assigned to the clone. The setvdiuuid command is just a personal preference.

3 thoughts on “VirtualBox UUID Change Script

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s