Page 1 of 1

proper escaping with guestcontrol; Windows guest/Linux host

Posted: 24. Jun 2015, 23:46
by wxl
Trying to write a little script that ensures our standard fonts are installed properly (we have had a couple corrupt font files, which is hard to detect by command line):

Code: Select all

#!/bin/bash

cd Fonts
for font in *; do
   # remove old fonts
   vboxmanage guestcontrol "XP" execute --image "c:\\windows\\system32\\cmd.exe" --username Admin --passwordfile pw --wait-stdout "/c del c:\\windows\\fonts\\${font}"
   fontname="$(echo $font | awk -F '.' '{print $1}')"
   # copy over new fonts
   vboxmanage guestcontrol "XP" execute --image "c:\\windows\\system32\\cmd.exe" --username Admin --passwordfile pw --wait-stdout --wait-stderr "/c copy s:\\fonts\\${font} c:\\windows\\fonts"
   # register new fonts
   vboxmanage guestcontrol "XP" execute --image "c:\\windows\\system32\\reg.exe" --username Admin --passwordfile pw --wait-stdout --wait-stderr "add \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts\" /v \"${fontname} (TrueType)\" /d ${font} /f"
done
Unfortunately, my problem is with the last command. Something is amiss with the escaping. I didn't want the shell to interpret the double quotes or the backslashes, so I thought this would be the right escaping, but it simply doesn't work. Does anyone know how we are supposed to deal with the shell's special characters and passing them over properly? Surely someone else does registry editing via the command line???

BTW, Windows gives me back "Error: Bad operation. Use /? for help"

FWIW running Kubuntu 14.04.2 with Windows XP SP3 with VirtualBox 4.3.28-100309~Ubuntu~raring.

Re: proper escaping with guestcontrol; Windows guest/Linux h

Posted: 25. Jun 2015, 16:50
by noteirak
What about with single quotes instead for the inner string?

Re: proper escaping with guestcontrol; Windows guest/Linux h

Posted: 25. Jun 2015, 20:02
by wxl
Single quotes would eliminate the shell from interpreting the font variable, so that would not be ideal. Even without using variables, it still doesn't work.

Re: proper escaping with guestcontrol; Windows guest/Linux h

Posted: 26. Jun 2015, 13:35
by frank
Which version of the VirtualBox Guest Additions did you install in your WinXP guest?

Re: proper escaping with guestcontrol; Windows guest/Linux h

Posted: 29. Jun 2015, 21:10
by wxl
I have looked all over to find this and have not had a lot of luck. What I can tell you is I'm running 4.3.28-100309~Ubuntu~raring.

Re: proper escaping with guestcontrol; Windows guest/Linux h

Posted: 29. Jun 2015, 22:06
by Perryg
With the guest open click on the machine tab at the top and then session information, or you can look in the guests log file and it will tell you there as well.

Re: proper escaping with guestcontrol; Windows guest/Linux h

Posted: 29. Jun 2015, 22:10
by wxl
And I swear I looked there before. Oh well, I see it now. 4.3.28 r100309, consistent with the version of VirtualBox.