Escaping a Windows path in CMD

2

This should be easy but it's escaping me. I've researched on the web and it confirms that if I surround a Windows path in quotes it takes care of spaces. But not with VirtualBox. What am I overlooking?

VBoxManage modifyhd "C:\Users\sam\VirtualBox VMs\Ubuntu 14 desktop.vdi" --resize 16480

=> 'C:\Users\sam\VirtualBox VMs\Ubuntu 14 desktop.vdi' (VERR_FILE_NOT_FOUND)

This attempt:

VBoxManage modifyhd C:\Users\sam\"VirtualBox VMs"\"Ubuntu 14 desktop.vdi" --resize 16480

=> Syntax error: Invalid parameter 'VMs"Ubuntu 14 desktop.vdi'

Closer, but no cigar.

VBoxManage modifyhd C:\Users\sam\'VirtualBox VMs'\'Ubuntu 14 desktop.vdi' --resize 16480

=> Syntax error: Invalid parameter 'VMs'\'Ubuntu'"

Ok, time for brute force. You know when you use tab to complete folder names? I changed directories down to sam and when I attempted to tab the name of "VirtualBox" it spat back the .virtualbox directory name which is not what I need. I attempted to quote the VirtualBox VMs in CMD and it could not find that folder name. That's probably a clue but I'm unsure how to search for a solution to that. What am I overlooking? thanx, sam

sam452

Posted 2014-11-19T00:24:17.813

Reputation: 161

rename "VirtualBox VMs" VirtualBoxVMs and rename "Ubuntu 14 desktop.vdi" Ubuntu14desktop.vdi :) – Paul – 2014-11-19T00:29:41.127

Yes, that would work normally. But the wrinkle is that VirtualBox maintains a record of the original path and it balks at finding this duplicate. Thx for offering as I hadn't thought of it yet. – sam452 – 2014-11-19T01:22:51.717

I was being flippant - but in any case, I think the VirtualBox config files are XML - or at least plain text, so you could update them too. Your first option should "just work" so I think this is some internal parsing issue with vbox itself. Someone will know. – Paul – 2014-11-19T01:34:38.860

I caught that. :) Your response was right on the money. What helped was to copy the path in VB's Media Manager, something I have missed. If you can update your response into the answer I'll accept that, thx. – sam452 – 2014-11-19T13:48:56.247

Answers

1

It looks like the best bet might be to remove the spaces from the path:

rename "VirtualBox VMs" VirtualBoxVMs 
rename "Ubuntu 14 desktop.vdi" Ubuntu14desktop.vdi

Then update the VirtualBox configuration to match. You can edit the config files directly with VB, or update the disk paths in media manager.

Paul

Posted 2014-11-19T00:24:17.813

Reputation: 52 173

Yes, the path is special to VirtualBox. Retrieving it from the Media Manager directly was the approach to go. Thx. – sam452 – 2014-11-19T22:34:10.510

2

My Advice would be to use the uuid. You can get it by using :

VBoxManage.exe showhdinfo "c:\MyMachine.vdi"

Or by using this trick : rename the vdi and then click on configuration of your vm and go to storage. Then try to add the renamed vdi as hard drive. You will get an error but if you expand the error message, you will see the uuid. So just copy it and paste it in the command:

VBoxManage modifyhd $UUID --resize 16480

Hope that this will help someone

rsabir

Posted 2014-11-19T00:24:17.813

Reputation: 121

This would have the same problem in the showhdinfo command as the path still contains spaces. – psusi – 2016-03-19T00:42:30.450

Yeah that's why I added the trick. – rsabir – 2016-03-19T09:30:17.600