VMware Cloud Community
wilson94t
Enthusiast
Enthusiast

Change install date after virtual machine clone.

My Windows OS guys would like to find a way to update the install date on windows after a VM has been cloned. This would be in the situation where sysprep is not run (and for argument sake, lets assume that it will not be run in this example).

Anyone have a, preferably command line script or tool that will output the number of seconds since Jan 1, 1970 on windows so I can slam it into :

\[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]

"SoftwareType"="SYSTEM"

"InstallDate"=dword:

IIRC, at least at one time the way microsoft was generating the time since epoch was not taking leapseconds into account and so the time was off by a few hours... that would even be ok for me. I don't need it to be exact.

There are tons of canned scripts for this on other platforms, but i haven't seen one on windows yet. Anyone have something to share?

0 Kudos
3 Replies
oreeh
Immortal
Immortal

If you have Perl installed this one helps

perl -e "print time();"

wilson94t
Enthusiast
Enthusiast

Sure, or simply:

perl -le 'print time'

but unfortunately, perl is not often available.

Earlier today, my coworker sent over the following. It does the job.

WScript.Echo "current time= " & Now

str_epoch= "01/01/1970 12:00 AM"

strInstalldate = DateDiff("s",str_epoch,Now)

WScript.Echo "seconds since epoch= " & strInstalldate

str_plus= DateAdd("s",strInstalldate,str_epoch)

WScript.Echo "seconds added to epoch = " & str_plus

Perhaps someone besides me will find it useful.

0 Kudos
DrewHeath
Contributor
Contributor

Years late, but maybe this will help someone else out, from PowerShell:

[math]::Round(((get-date) - (get-date 1/1/1970)).TotalSeconds,0)

0 Kudos