0

How i can change date and time format? I need replace ":" to "_" in time. Below my code:

<SetProperty Before='AppSearch' Sequence='both' Id='HOSTNAME' Value="[ComputerName]_[Time]_[Date]">NOT HOSTNAME</SetProperty>
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164

1 Answers1

0

The MSI SDK documents this pretty well: Time Property:

The format of the value depends upon the user's locale, and is the format obtained using GetTimeFormat function with the TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER option.

So the user's locale will affect the format, and then you probably need to use a custom action to get the formatting the way you want it. I can't think of any other way to do it.

All time silliest VBScript: (it is very late)

MsgBox Day(Now) & "_" & Month(Now) & "_" & Year(Now) & "_" & Hour(Now) & "_" & Minute(Now) & "_" & Second(Now)

And just a hint for how to insert custom actions can be found here: How to execute conditional custom action on install and modify only?


Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • Added a link above on how to use custom actions in your package. Also [see this answer for WiX sample links and how-to tips](https://stackoverflow.com/a/25005864/129130). – Stein Åsmul Dec 14 '18 at 06:37
  • Like this? - `` `` `NOT HOSTNAME` – Anuar Mukatov Dec 14 '18 at 07:26
  • Can't test this right now, and hard to tell without knowing more about what you need to do, but you need to use a regular custom action element inserted into the `InstallExecuteSequence` and the `InstallUISequence` and not just a SetProperty element. [See here, bottom](https://stackoverflow.com/a/52377800/129130). If it does not run, then there is an error in the script. [Check the MSI log](http://www.installsite.org/pages/en/msifaq/a/1022.htm). Try to create a dummy VBScript that does nothing that can go wrong: `MsgBox "Hello!"` to see if you have a "heartbeat". – Stein Åsmul Dec 14 '18 at 08:37
  • It is always wrong to use a custom action if you do not need them. [Here is a description of why](https://stackoverflow.com/questions/46179778/why-is-it-a-good-idea-to-limit-the-use-of-custom-actions-in-my-wix-msi-setups/46179779#46179779). If you can avoid them, please do so. However, sometimes they are unavoidable. [VBScript custom actions are particularly frowned upon](https://blogs.msdn.microsoft.com/astebner/2005/02/07/dont-use-vbscriptjscript-to-write-your-custom-actions/), but can help avoid dependencies on the .NET framework for trivial operations (such as just setting a property). – Stein Åsmul Dec 14 '18 at 08:40