2

I have a situation where I want to initialize APPDIR via a C# custom action, but I only want to do so if APPDIR wasn't supplied as a command line argument (there's custom logic which occurs in our bootstrapper which I want to use in setting the default path for the MSI as well, as we ship both).

I've tried looking through the tables but it doesn't appear as though the command line arguments are set there.

The logs output:

MSI (c) (A0:78) [16:40:33:995]: Command Line: APPDIR=C:\WHAT CURRENTDIRECTORY=E:\ CLIENTUILEVEL=0 CLIENTPROCESSID=10912

when I set APPDIR=C:\WHAT on the command line, but I cannot find a place to check whether a value was in fact set by command line (rather than by default value, UI or a custom action).

adamdc78
  • 1,153
  • 8
  • 18
  • Interesting question. I've done this http://stackoverflow.com/a/6312014/1755158 but would like to see an solution independent of msiexec. – cory.todd Oct 01 '15 at 23:57
  • I'm actually looking to use msiexec, but I want to query the command line parameters received by the MSI in a condition within the MSI. I can hack it by waiting until the UI dialog is shown, but that doesn't work so well for silent installations. – adamdc78 Oct 01 '15 at 23:59
  • How about set APPDIR to a default value(e.g. "ChangeMe"), then schedule your custom action prior to Installlnitialize in the InstallExecuteSequence with a condition that it only runs if APPDIR equals that default value. I assume there's a specific reason you're using a C# Custom Action and not just setting a default value on the property which would eliminate the need for the custom action altogether. – Rick Bowerman Oct 02 '15 at 15:15
  • Default value would work if there's no validation logic on it from Advanced Installer at startup; it's a bit of a hack, though. Trying to avoid that if possible, but in the end that may be my solution. – adamdc78 Oct 02 '15 at 16:43

1 Answers1

0

You should be able to do this by just looking for the property at various stages in the install. If it is present before the UI sequence starts (and before any custom actions that might change it) then by definition it must have been set on the command line. So you can have a property SETONCOMMANDLINE and have a type 51 custom action (a set property CA) that sets SETONCOMMANDLINE to true with the condition APPDIR, so it will be set only if APPDIR was already set.

After the UI sequence (and before anything else that might change it) do the same with a SETINUI property. Have a property set CA that sets SETINUI to true conditioned on -APPDIR AND NOT SETONCOMMANDLINE- so SETINUI will be true if it's been set to a value but it wasn't via the command line. But it might be simpler to have your UI set SETINUI at the same time that it sets APPDIR.

By the time you need to know how it was set you can do it if -NOT SETINUI AND NOT SETONCOMMANDLINE-

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • Unfortunately it is an Advanced Installer property which has a default value. The user may have set the SAME value on the command line and inspection of this nature will not tell me whether that is the case. – adamdc78 Oct 03 '15 at 23:13
  • What do you mean by "default value"? If that means something like AI generating a CA to set the default value then just find where that happens in the MSI file and check before that, which is why I say "before any custom actions that might change it", because it can have a default value (such as Program Files) only if AI generates a CA to do that. In the MSI you'd see a type 51 CA to set it that may not be exposed in the AI IDE. I also suggest removing the WiX tag! – PhilDW Oct 04 '15 at 19:26
  • Will give this a shot tomorrow. Thank you for the additional info! – adamdc78 Oct 04 '15 at 22:10