[SOLVED] How-to use guestcontol execute on shell commands?

This is for discussing general topics about how to use VirtualBox.
Post Reply
Technologov
Volunteer
Posts: 3342
Joined: 10. May 2007, 16:59
Location: Israel

[SOLVED] How-to use guestcontol execute on shell commands?

Post by Technologov »

Hi All,

Host: Windows 7 x64, VBox 4.0.8
Guest: Windows XP

I did this:
> VBoxManage guestcontrol execute "Windows XP VM01" "ipconfig.exe" --arguments " /all" --username Administrator --password 123456 --wait-for stdout
..and this works.

But a similar command FAILs:
> VBoxManage guestcontrol execute "Windows XP VM01" "dir" --arguments " C:\" --username Administrator --password 1234
56 --wait-for stdout

The problem is that in Windows, 'dir' command is not a separate executable, unlike Linux 'ls', but is part of the system shell, "cmd.exe"

Any ideas?
-Technologov
Leak
Posts: 242
Joined: 31. Mar 2009, 13:00
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Debian Testing, Windows XP, Windows Server 2003/2008 R2

Re: How-to use guestcontol execute on shell commands?

Post by Leak »

Technologov wrote:The problem is that in Windows, 'dir' command is not a separate executable, unlike Linux 'ls', but is part of the system shell, "cmd.exe"
That's your answer right there - run cmd.exe in the VM and pass "/c" (so it terminates) followed by whatever command(s) you want executed as it's arguments...

np: Death Cab For Cutie - State Street Residential (You Can Play These Songs With Chords)
Technologov
Volunteer
Posts: 3342
Joined: 10. May 2007, 16:59
Location: Israel

Re: How-to use guestcontol execute on shell commands?

Post by Technologov »

Yes, and it doesn't work either:
C:\Program Files\Oracle\VirtualBox>VBoxManage guestcontrol execute "Windows XP VM01" "cmd.exe" --username Administrator --password 123456 --arguments " /c dir C:\" --wait-for stdout

update:
This works:
C:\Program Files\Oracle\VirtualBox>VBoxManage guestcontrol execute "Windows XP VM01" "cmd.exe" --username Administrator --password 123456 --arguments " /c dir C:\ >1" --wait-for stdout

Just had to redirect to STDOUT ! Thanks.

-Technologov
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: How-to use guestcontol execute on shell commands?

Post by mpack »

@Leak - your contributions to this site are proving to be valuable, but your attention seeking sig is irritating: it is noise in an otherwise useful signal. I suggest you ditch it.
Post Reply