Windows XP:
Our virtual XP can be accessed through Remote Desktop or other similar program. However, this only allows you to Log Off or Disconnect. In other words you cannot restart XP from a remote session. You would have to do that from Virtualbox or command line in Debian, or with a remote command line from your local machine.
>> I've had some issues issuing the acpi shutdown command from Debian. XP shows a warning message and doesn't proceed with the shutdown, whereas there's no way to connect remotely at that point. <<
I think it's easier if we just put a batch file right in XP's Desktop and use that for a quick reboot or shutdown. Create the following file on notepad:
@ECHO OFF
ECHO 1.Shutdown
ECHO 2.Restart
SET /P choice=Enter your choice:
IF %choice%==1 GOTO Choice1
IF %choice%==2 GOTO Choice2
:Choice1
shutdown -f -s -t 5
:END
:Choice2
shutdown -f -r -t 5
:END
PAUSE
and save it on the desktop under the name "action.bat" or something else meaningful. Option one/two sends the power off/reboot signal respectively within 5 seconds of execution. The -f switch makes sure every running process is stopped before the system shuts down.
Debian:
Since this is the host OS, you might want to have a few scripts laying around to make things easier. The Virtualbox cli is not bad at all but if you don't want to have to look up the commands every time, you can use the following perl script.
#!/usr/bin/perl
use strict;
use Getopt::Long;
### CALL MAIN ###
&main();
sub main()
{
### DEFAULTS ###
my $start = '';
my $pause = '';
my $resume = '';
my $reset = '';
my $poweroff = '';
my $shutdown = '';
### FLAGS ###
GetOptions
(
'start=s' => \$start,
'pause=s' => \$pause,
'resume=s' => \$resume,
'reset=s' => \$reset,
'poweroff=s' => \$poweroff,
'shutdown=s' => \$shutdown
)
or die "Incorrect usage!\n";
### ACTIONS ###
if ($start)
{ system ("nohup vboxheadless -startvm $start \&\n"); }
elsif ($pause)
{ system ("VBoxManage controlvm $pause pause\n"); }
elsif ($resume)
{ system ("VBoxManage controlvm $resume resume\n"); }
elsif ($reset)
{ system ("VBoxManage controlvm $reset reset\n"); }
elsif ($poweroff)
{ system ("VBoxManage controlvm $poweroff poweroff\n"); }
elsif ($shutdown)
{ system ("VBoxManage controlvm $shutdown acpipowerbutton\n"); }
else
{ &help_msg(); }
}
sub help_msg()
{
system ("clear");
print q{
Virtualbox cli perl script
Erikton Konomi, May 2013
Use:
-start [VM Name] # start the VM
-pause [VM Name] # pause the VM
-resume [VM Name] # resume the VM
-reset [VM Name] # hard reset the VM
-poweroff [VM Name] # hard power down the VM
-shutdown [VM Name] # soft power down the VM, send acpi signal
};
}
Save it as "vb" or some other short meaningful name and make it an executable file by doing:
erik@debian: chmod +x vb
Make sure Perl is happy with the script and it produces no errros:
erik@debian: perl vb
Run it using the switches. For example to pause the XP virtual machine, named Media-XP:
erik@debian: ./vb -pause Media-XP