8

When an install completes successfully, the date and time and some other info needs to be written to the registry. How can a date be generated and how do you know if an install was completed successfully? (writing to the registry with wix is not a problem).

MX4399
  • 1,519
  • 1
  • 15
  • 27

3 Answers3

10

What about using standard MSI properties Date and Time?

Note: Be warned that despite the documentation indicating the date will always be in the MM/DD/YYYY format, this is not in fact the case. A verbose MSI log on my system (in Australia) shows the property in DD/MM/YYYY format... e.g.:

Property(S): Date = 21/04/2010
saschabeaumont
  • 22,080
  • 4
  • 63
  • 85
Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
  • Example usage : – MX4399 Apr 20 '10 at 17:34
  • From the MSDN doc Yan referenced it indicates "The format of the value depends upon the user's locale, and is the format obtained using GetDateFormat with the DATE_SHORTDATE option. The value of this property is set by the Windows Installer and not the package author.". – MX4399 Apr 21 '10 at 05:48
8

For both date and time here is some sample code.

<RegistryValue Id="InstallDateTime"
               KeyPath="yes"
               Name="InstallDateTime"
               Value='[Date] [Time]'
               Type="string" />

enter image description here

If you want to use separator you can simply add it as text like:

<RegistryValue Id="InstallDateTime"
               KeyPath="yes"
               Name="InstallDateTime"
               Value='[Date]-[Time]'
               Type="string" />

enter image description here

Andreas
  • 5,393
  • 9
  • 44
  • 53
Rikin Patel
  • 8,848
  • 7
  • 70
  • 78
0

Env variables??


Can you access environment variables like PATH etc. ??

  • These return the current system date and time...

    You might want to access %DATE% & %TIME%

Alternately, since You are able to access the Registry, You can access the Env vars in the registry itself:

HKEY_CURRENT_USER\Environment\<variable>

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\<variable>

GoodLUCK!!

Community
  • 1
  • 1
TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130
  • Interesting - but I cannot find a WIX method to read a env var - the Environment element can "create|set|remove" only. Looking at the registry entries on my machine does not show date or time entries. – MX4399 Apr 19 '10 at 08:12
  • http://stackoverflow.com/questions/11181847/windows-environmental-variable-for-month-year – Brian Cannard Dec 12 '12 at 12:28