VBoxManage and filesnames with whitespaces

Discussions about using Windows guests in VirtualBox.
jorgensen
Posts: 589
Joined: 20. Oct 2009, 01:22
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows

Re: VBoxManage and filesnames with whitespaces

Post by jorgensen »

Maybe \a is considered as a beep character in the C code.
Why not use slash (/) for path separation to get around the backslash problem.
kasi
Posts: 9
Joined: 3. Oct 2011, 02:59
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Win7

Re: VBoxManage and filesnames with whitespaces

Post by kasi »

jorgensen wrote:Maybe \a is considered as a beep character in the C code.
Why not use slash (/) for path separation to get around the backslash problem.
This unfortunately doesn't work as well. I'm surprised that nobody else ever ran into a similar problem when trying to pass parameters with whitespaces to programs via vboxmanage.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: VBoxManage and filesnames with whitespaces

Post by mpack »

I - along with most sane people - tend to avoid command lines. :D Seriously, only a fraction of users use the command line, of those only a fraction need to pass command lines via another command line, and of those only a fraction would need to pass spaces, and of those only a fraction would decide that they couldn't work around it. Not many people left after that!

Your difficulty also seems to an obscure one related to who exactly parses the command line and what code they use. I use Windows Hosts and Windows Guest and would not expect to have this problem.

I did attempt a (quick) look into the VBoxManage source tree for a command line parser, so we could settle this issue of how it treats doubled up quotes, mixed quote types, slashes etc. Unfortunately I didn't find it. It may be tucked away in a folder somewhere, but it looks like they rely on a standard library function to create the argv[] list for main(), in which case I could never be exactly sure about implementation details.
Tom-
Posts: 1
Joined: 17. Apr 2012, 17:54

Re: VBoxManage and filesnames with whitespaces

Post by Tom- »

I have been fighting this problem for months in a very similar way as in the thread above. The workaround I've found is to construct in the host OS the complete command that is to be run in the guest, and put it in a batch file, and call the batch file with VBoxManage:

Code: Select all

echo "C:\WINDOWS\system32\cmd.exe /C start /B \"VB_XP\" \"$filename\"" > /tmp/VBXP2.bat
VBoxManage --nologo guestcontrol XP execute "C:\WINDOWS\system32\cmd.exe"  --username u --password p /C start /B Y:\\tmp\\VBXP2.bat
Note that:
- If the first argument of the start command is enlosed in double quotes, it thinks that it is the window title. For this reason I included a dummy title.
- The batch file location needs to be accessible from both host and guest OSes.
- You may want to preprocess the $filename to handle special characters, and to make sure the correct file path is passed to the guest OS.
Post Reply