Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

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

Writer Matthew Martinez

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.

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.

1

5 Answers

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:

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

The following option allows to set an offset in milliseconds:

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

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
1

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 "".

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
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

  • 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

Just some info that can be of help to be known, the command:

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

Can be run with the "VM name" guest running and it take effect inmediatly (at least on a Windows Host and a Windows Guest).

After run it (also is the guest is running) you can change the date and it does not revert back to host date; there is no need to shutdown or reboot the guest.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy