Cadzow Knowledgebase

Normal view

Scripting: Determine Installation Date

Windows stores the installation date in the registry but encodes it as the number of seconds since 01/01/1970 so this is difficult to deal with from a script. However the WMIC command provides a more useful format:

wmic os get installdate /value

returns:

InstallDate=20120815161839.000000+570

The first step is to parse out the date/time component and store it in a variable:

for /f "skip=1 tokens=2 delims==." %%x in ('wmic os get installdate /value') do set InstallDateTmp=%%x

Next, InstallDateTmp can be rebuilt by taking the various segments of itself and adding punctuation:

set InstallDateTmp=%InstallDateTmp:~0,4%-%InstallDateTmp:~4,2%-%InstallDateTmp:~6,2% %InstallDateTmp:~8,2%:%InstallDateTmp:~10,2%:%InstallDateTmp:~12,2%

Thus InstallDateTmp will contain 2012-08-15 16:18:39.



Copyright © 1996-2023 Cadzow TECH Pty. Ltd. All rights reserved.
Information and prices contained in this website may change without notice. Terms of use.

Question/comment about this page? Please email webguru@cadzow.com.au