Using virtual box is it possible to set your virtual machine time to be different from host time

34

15

Using virtual box is it possible to set your virtual machine time to be different from host time. Say 1 year into the past.

If I wanted to run the windows XP images provided by Microsoft from here.
http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11575

It is noted for the XP image that:

Expires: This image will shutdown and become completely unusable on February 14, 2013.

It is one of the better ways to test IE 6, and IE 7. Other XP typical tests.

nelaaro

Posted 2013-01-22T09:56:56.980

Reputation: 9 321

http://browsershots.org/ – ta.speot.is – 2013-01-22T10:00:18.930

Answers

39

It's no problem at all. Just remember to disable the time synchronisation in the VirtualBox Guest Additions, then set the date+time in the virtual machine as you like. There is also an option to go into the Virtual BIOS and set the date+time there, if that's needed at install time.

This command disables the synchronization:
http://www.virtualbox.org/manual/ch09.html#disabletimesync

VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1

The following option allows to set an offset in milliseconds: http://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm

VBoxManage modifyvm "VM name" --biossystemtimeoffset <msec>

Stefan Seidel

Posted 2013-01-22T09:56:56.980

Reputation: 8 812

Ok how do you do that. – nelaaro – 2013-01-22T10:03:54.607

Do what? Please be more specific? – Stefan Seidel – 2013-01-22T10:29:42.787

3disable the time synchronisation & go into the Virtual BIOS and set the date+time there – nelaaro – 2013-01-22T10:31:38.063

2

Disable time sync: there's a checkbox in the VirtualBox Guest Additional. Alternatively: http://www.virtualbox.org/manual/ch09.html#disabletimesync For the BIOS: hit F12 (I think) during the VM startup, and here are command line tools described: http://www.betaarchive.com/forum/viewtopic.php?t=20071 on how to change the BIOS time.

– Stefan Seidel – 2013-01-22T11:32:49.250

3

Example of a windows powerShell script

startVM.ps1

# Starts the VM always on the date 12/30/2016

$tempo = ""+([datetime]"12/30/2016" - [datetime]::Now).TotalMilliseconds
$tempo = ""+[math]::Round($tempo)
$nome = "virtualMachineName"

& ${env:ProgramFiles}\Oracle\VirtualBox\VBoxManage setextradata $nome "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1

& ${env:ProgramFiles}\Oracle\VirtualBox\VBoxManage modifyvm $nome --biossystemtimeoffset $tempo

& ${env:ProgramFiles}\Oracle\VirtualBox\VBoxManage startvm $nome

eliseu

Posted 2013-01-22T09:56:56.980

Reputation: 31

0

Based on the ".ps1" (Windows PowerShell script) example above, I've written a regular ".bat" script file to change the clock time at which the VirtualBox's virtual machine starts.

The desired start time is set at variable "TEMPO_START_TIMESTAMP" in epoch format. You can get your desired start time epoh equivalent at "http://www.timestampconvert.com/".

The name of the VirtualBox's virtual machine to be started is needed in variable "NOME" (same nomenchature used in the ".ps1" script above).

echo off
echo %time%

set NOME="Windows_7_x64"

set TEMPO_CS_2_MS=0
set TEMPO_S_2_MS=000

rem # Starts the VM always on the date 07/11/2014 - 11h58
rem http://www.timestampconvert.com/

set   TEMPO_START_TIMESTAMP=1415361480

for /f "delims=" %%x in ('cscript /nologo toEpoch.vbs') do set epoch=%%x
rem %epoch%

set TEMPO_CURRENT_TIMESTAMP=%epoch%
rem set TEMPO_CURRENT_TIMESTAMP=1544518714

set /A TEMPO_TEMP=(%TEMPO_START_TIMESTAMP%-%TEMPO_CURRENT_TIMESTAMP%)

call set TEMPO=%TEMPO_TEMP%%TEMPO_S_2_MS%
rem %TEMPO_TEMP%
rem %TEMPO%

c:\Progra~1\Oracle\VirtualBox\VBoxManage setextradata %NOME% "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1
c:\Progra~1\Oracle\VirtualBox\VBoxManage modifyvm %NOME% --biossystemtimeoffset %TEMPO%
c:\Progra~1\Oracle\VirtualBox\VBoxManage startvm %NOME%

You'll also need the current time in epoh format, for this use the following script (save as "toEpoch.vbs", this visual basic script is called from the ".bat" script above):

WScript.Echo DateDiff("s", "01/01/1970 00:00:00", Now())

To run the virtual machine, simply execute the ".bat" script file above. No need to open the "Oracle VM VirtualBox Administration" interface.

I hope this helps.

Regards

Txane

Posted 2013-01-22T09:56:56.980

Reputation: 1

0

  • You should be on the path of VBox, it almost be like that (C:\Program Files\Oracle\VirtualBox)

  • open your Virtual Box and from Start menu > CMD >cd C:\Program Files\Oracle\VirtualBox

  • The prompt will be like this C:\Program Files\Oracle\VirtualBox>
  • Then write the following command: [remember to get your VBox Name] VBoxManage setextradata "Put_your_VM_Name"
    "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1
  • Full command will be like this in the CMD
    C:\Program Files\Oracle\VirtualBox>VBoxManage setextradata "Put_your_VM_Name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1

after implementing these steps you will be able to change the VBox date and time.

Command of sync Data and time

Good Luck

SunwayCo

Posted 2013-01-22T09:56:56.980

Reputation: 1