Created
May 5, 2017 08:45
-
-
Save racitup/1bf9b9ad265e488f7b3f43063b367a0e to your computer and use it in GitHub Desktop.
Set the date of a JLR SDD V145 Diagnostics Virtualbox VM to a known date using python3 script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# Script to reset JLR SDD VM time back | |
# Note the limited install authentication access is only valid within a 24 hour period | |
# The VM date must be within this period, not before (system date tamper detected error) | |
# and not afterward (expired error) | |
import sys | |
from datetime import datetime, date | |
from subprocess import call | |
# Warning | |
print('\nWARNING: The JLR SDD Virtual Machine MUST be shutdown!!\n') | |
# VM Name | |
vmname = 'WinXP JLR Diagnostics' | |
# Y, M, D expires at 3rd May 2017 11.37PM | |
reqd = date(2017, 5, 3) | |
print('Setting JLR SDD VM date to {}\n'.format(reqd.strftime('%d %B %Y'))) | |
nowd = datetime.now().date() | |
# Get the time difference from now: | |
tdiff = reqd - nowd | |
elapsedms = int(tdiff.total_seconds()*1000) | |
def run(cmd): | |
"Helper function to run shell command" | |
args = {'stdout': sys.stdout, 'stderr': sys.stderr, 'shell': True} | |
ret = call(cmd, **args) | |
print('\n{}, returned: {}\n---------\n'.format(cmd, ret)) | |
cmd = 'VBoxManage setextradata "{}" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1'.format(vmname) | |
run(cmd) | |
cmd = 'VBoxManage modifyvm "{}" --biossystemtimeoffset {}'.format(vmname, elapsedms) | |
run(cmd) | |
print('\nPress Enter to continue...') | |
input() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment