I know this is an old topic, but as
msa.operations said (5 years ago) it's still the 1st result on Google when searching for "VirtualBox disable time synchronization".
After "upgrading" from Virtual PC 2007 to VirtuaBox v5.0.4 I bumped into the same problems:
1. VirtualPC disables time synchronization if the following code is manually added between mouse and video in the guest's config file (.VMC):
Code: Select all
<components>
<host_time_sync>
<enabled type="boolean">false</enabled>
</host_time_sync>
</components>
VirtualBox does the same by either not installing Guest Additions (not recommended) or by running the following line everytime Guest Additions are installed / updated:
Code: Select all
VBoxManage setextradata "GuestName" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1
2. VirtualPC automatically saves the guest's current date/time in the .VMC file so it's loaded again on next startup. The line is similar to this:
Code: Select all
<time_bytes type="bytes">21001900110005310715</time_bytes>
VirtualBox doesn't support this (that I know of, please correct me if I'm wrong),
but there is a workaround for XP Professional and possibly other versions of Windows. VirtualBox normally uses the host's time when the guest is started, so the workaround uses a batch file to save current date/time to a text file inside the guest during shutdown, then loads it again during login, which is enough for me. This is how it's done:
- double click on the clock, go to "Internet Time" tab and disable online time synchronization;
- create the file C:\datetime.cmd inside the virtual machine;
- paste the following code inside:
Code: Select all
@echo off
setlocal enabledelayedexpansion
if /i [%1]==[save] (
for /f %%a in ('date /t') do set "ldt=%%a"
for /f %%a in ('time /t') do set "ldt=!ldt! %%a"
echo !ldt! > C:\datetime.txt
)
if /i [%1]==[load] (
set /p ldt=<C:\datetime.txt
for /f "tokens=1*" %%a in ("!ldt!") do (
date %%a
time %%b
)
)
- Open policy editor (Start > Run > gpedit.msc);
- Navigate to Computer Configuration > Windows Settings > Scripts (Startup/Shutdown);
- Add "C:\datetime.cmd save" on Shutdown and "C:\datetime.cmd load" on Startup.
Now Windows XP saves the date and time to C:\datetime.txt on shutdown and reloads it on startup. This is what was added to the registry with the previous commands, maybe it will work for XP Home and other versions of Windows that don't have Policy Editor, just copy/paste the lines to a .reg file and try them.
Warning: Please manually check the keys of your registry. If you already have a Startup\0\0, Startup Startup\0\1, etc please change the last number in the line below to an unused one so it doesn't overlap an existing script. The same applies to Shutdown\0\0, Startup Startup\0\1, etc
Code: Select all
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\Machine"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0\0]
"Script"="c:\\datetime.cmd"
"Parameters"="save"
"ExecTime"=hex(b):df,07,09,00,02,00,16,00,0a,00,03,00,09,00,6b,02
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup\0]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\Machine"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup\0\0]
"Script"="C:\\datetime.cmd"
"Parameters"="load"
"ExecTime"=hex(b):df,07,09,00,03,00,17,00,0a,00,35,00,1f,00,e0,02
Have fun!