proper escaping with guestcontrol; Windows guest/Linux host

Discussions about using Windows guests in VirtualBox.
Post Reply
wxl
Posts: 12
Joined: 24. Jun 2015, 23:28
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: mainly Windows
Location: Cascadia
Contact:

proper escaping with guestcontrol; Windows guest/Linux host

Post 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.
Last edited by wxl on 25. Jun 2015, 20:03, edited 1 time in total.
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

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

Post by noteirak »

What about with single quotes instead for the inner string?
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
wxl
Posts: 12
Joined: 24. Jun 2015, 23:28
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: mainly Windows
Location: Cascadia
Contact:

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

Post 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.
frank
Oracle Corporation
Posts: 3362
Joined: 7. Jun 2007, 09:11
Primary OS: Debian Sid
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows
Location: Dresden, Germany
Contact:

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

Post by frank »

Which version of the VirtualBox Guest Additions did you install in your WinXP guest?
wxl
Posts: 12
Joined: 24. Jun 2015, 23:28
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: mainly Windows
Location: Cascadia
Contact:

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

Post 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.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

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

Post 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.
wxl
Posts: 12
Joined: 24. Jun 2015, 23:28
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: mainly Windows
Location: Cascadia
Contact:

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

Post 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.
Post Reply