Windows 7 - CustomAction help

Asked By Micus
13-Nov-09 03:53 PM
Hello,

[VS 2003 Setup/Deployment project, Win Installer v2.0, C++]

I need some advice on CustomActions. My deployment project currently
has a CA during the install phase, which users enter a product key to verify
they are legitimate owners of the software. When the product key is
verified, the CA places an entry in the registry, which is referenced every
time the software is run. The CA is a dll with Install(MSIHANDLE) defined.
Everything works fine on all OS's except for Vista. I have found that with
Vista, any registry modifications have to be done in the Commit phase, not
the Install phase, of installation. If I move the CA to the Commit phase,
the installation is not rolled back when an invalid product key is entered.
What I need is a way to pass data entered in the Install phase CA to a CA in
the Commit phase to write info to the registry.

So far, I have tried defining 2 functions in the CA dll, Install(MSIHANDLE)
and Commit(MSIHANDLE). I tried using MsiSetProperty()/MsiGetProperty() to
pass data between the Install and Commit phases but  MsiSetProperty() fails
to create an installer property.

Install(MSIHANDLE mh)
{.
MsiSetProperty(mh, "NewProp", "DataString"); // returns non ERROR_SUCCESS
.}

I have also tried passing the data by writing a temp file in the windows
directory and reading it in the Commit CA - this also fails on Vista. The
file is not written.

The only other option that I can think of is using the clipboard but I was
hoping there was a cleaner way to pass the data. Another solution would be
to give the CA the rights of the user who launched the Install, but the
project does not have options to set the NonImpersonate flag for CAs.

Thanks In Advance,
M
Windows Installer
(1)
Visual Studio
(1)
MsidbCustomActionTypeNoImpersonate
(1)
Vista
(1)
MsiSetProperty
(1)
MsiGetProperty
(1)
WinME
(1)
NonImpersonate
(1)
  Wilson, Phil replied to Micus
13-Nov-09 05:56 PM
the Commit phase, not the Install phase, of installation."

I think you are misunderstanding something here. Anyway, the issue is that
not until VS 2008 do VS setup projects do the right thing, which is to run
its custom actions without impersonation so they can in fact run elevated,
and yes, no versions of Visual Studio allow you to tweak those settings from
the UI. The UAC behavior is that even if you are administrator the
impersonated custom actions run as limited user, so they cannot do those
things requiring higher privilege.

--
Phil Wilson
The Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972
  Micus replied to Wilson, Phil
13-Nov-09 06:44 PM
Thank you for your response. My misunderstanding of the msi tech is not a
surprise, but I am trying. Do you have suggestions on how to pass data
between an Install CA and Commit CA?  I have VS 2003 EA mainly do to my apps
targeting Win 98 through the current OS's using VC++ and the Win32 API. VS
2008 does not target the old OS's or I'd buy it tonight.

Regards,
-M

in
from
defined.
not
phase,
CA
to
ERROR_SUCCESS
The
was
be
  Kalle Olavi Niemitalo replied to Micus
14-Nov-09 07:22 AM
Do not use a commit CA.  Put the code in the install CA, and set
the msidbCustomActionTypeNoImpersonate flag.  To do that, either
postprocess the MSI file generated by Visual Studio or switch to
some other tool entirely.  The postprocessing you could do with
WiRunSql.vbs or perhaps with Dennis Bareis' MAKEMSI.
  Phil Wilson replied to Micus
14-Nov-09 02:23 PM
Not sure what you mean by "VS 2008 does not target the old OSs". You mean in
general or just setup projects?

--
Phil Wilson
[Microsoft MVP-Windows Installer]
  Micus replied to Phil Wilson
14-Nov-09 03:37 PM
Thank you Kalle. Unfortunately, I do not have access to the
msidbCustomActionTypeNoImpersonate  [VS 2003 Setup/Deployment project, Win
Installer v2.0, C++].

Phil, from what I have read, the 2008 c++ compiler does not target Win98-WinME
OS's for non .NET applications.

Also, after creating some installation packages, I have found that I cannot
create a registry entry be it in the Install or Commit phase using CA's
(thus my misunderstanding?). I 'assumed' that I could...

So, my new question is: Given the setup project on VS 2003, is there any way
to create a registry entry in HKEY_LOCAL_MACHINE using a Custom Action?

I apologize for taking the scenic route,
-M


in
a
VS
done
that
phase,
a
  Phil Wilson replied to Micus
15-Nov-09 03:32 PM
applications."

Yes, but you want their setup projects that run custom actions with no
impersonation, not their C++ compiler. The only likely requirement is an
updated Windows Installer engine, 2.0 or 3.0.

To run inpersonated and elevated you would  have to launch the MSI from an
elevated prompt.

What are you writing to the registry that needs a custom action? (Rather
then the IDE)
--
Phil Wilson
  Micus replied to Phil Wilson
16-Nov-09 03:10 PM
I am writing a software key to the registry that the installed applications
check each time they are run. During installation, the CA prompts the user
to enter their software key. If the key is valid, the install completes,
otherwise the install is aborted. I have been playing around with
MsiSetProperty() in my CA to pass the key back to the installer, but the
function returns an invalid handle error. I am not even sure, even if I could
create a property, that I could use the property to create a registry entry
within the installer instead of the CA.

I think at this point, I need to either run a separate app before
installation, or pickup VS 2008 and hope I can configure an install package
that will satisfy my requirements.

Phil, Thank you for all your help.
-M

Win
cannot
mean
not
my
API.
to
  Wilson, Phil replied to Micus
16-Nov-09 05:55 PM
Where does the key come from? If it is in an installer property than you can
just write it to the registry using the setup's Registry IDE in the same
whay you would  store the application folder by writing [TARGETDIR] or the cd key
using [PIDKEY] .
--
Phil Wilson
The Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972
  MikeMio replied to Micus
19-Nov-09 11:12 PM
If I recall correctly (it is a bit hazy), in order to get the right
privileges for Vista, when using the older Visual Studio deployment projects,
you have to manually adjust the custom action type. This because, as Phil
mentioned, the older setup projects don???t set it correctly.

So, after creating the msi file, you have to manually adjust the custom
action type by turning on bit 12 (i.e. adding 0x800).

One way to do that is by opening Orca, finding the Custom Action table and
locating your function (your function name will appear in the 'Target'
column). Then take the value in the ???Type??? column and add 2048 (0x800) to it.
Save the changes and that???s it. It should work in Vista now.

I recall a Microsoft employee blog entry on the subject around the time
Vista was coming out but I can???t find a link.

Mike
  legalize+jeeve replied to Micus
20-Nov-09 05:27 PM
[Please do not mail me a copy of your followup]



The main thing you are bashing your head against here is the silly
constraints imposed on CAs by the VS.NET deployment project model.

The architecture I would use for your problem is this:

1) Dialog where the user is prompted for the serial number
information.  A custom action associated with the "Next" button on
this dialog validates the serial number and displays an error dialog
if the serial number is invalid.  This will prevent the install from
even starting if the serial number is invalid.  (There are some
slight additional work you want to do if you want to support a
UI-less install.)

2) If the serial number is valid, it is stored in a public property.
A public property is communicated between the UI phase and the system
modification phase.

3) The standard Registry actions are used to store the value of the
public property in the registry.

This approach still requires a custom action, but it is simpler than
the custom action you are attempting to write and it avoids all the
impersonation issues you are bumping into.

However, VS.NET deployment projects do not support directly authoring
this sort of scenario.  I always recommend using WiX instead of the
deployment project stuff because it is insufficient for all but the
simplest of installs.  You could easily recreate your installation as
a WiX project by using the WiX tools to decompile your MSI into a WiX
source file.
--
  MikeMio replied to MikeMio
26-Nov-09 12:21 PM
In case you are still working on this, I found the blog article. It is here:
https://blogs.msdn.com/astebner/archive/2006/10/23/mailbag-how-to-set-the-noimpersonate-flag-for-a-custom-action-in-visual-studio-2005.aspx
help
Windows Installer SDK Vs Visual Studio Installer Windows 7 I am not getting the difference between both of the above given. Are they Discussions SDK (1) VS (1) MSI (1) FamilyId (1) VSI (1) CDCCF (1) UI (1) Windows (1) Windows Installer SDK = the documentation and a few tools related to Windows Installer. This used to be
Windows Installer Issue Windows 7 Hello, I wonder if anyone can help? I seem to be having a problem with windows installer, I am not getting an error but everytime I go into a new application, i e. firefox, explorer, word, control panel, I get the windows installer pop up box come up saying professional 2003" then back to "preparing to install" and m not sure what has happened and why it is doing this!! Can anyone help? Windows Vista Discussions Windows Installer (1) Word (1) XP (1) Monday (1) Cillin (1) E6CD4E0F5E1A (1
Windows installer service cant start Error 193:0xc1 ??? Windows 7 Im getting the error when the windows installer service tries to start. Also i Cant install any msi because i get the "The Windows Installer Service could not be accessed. In the event viewer I get the foolwoing error events The Windows Installer service failed to start due to the following error: Windows Installer is not a
Minor upgrade and installation Windows 7 I created a new Windows Installer as a minor upgrade over a previous Windows Installer. This means that the PackageCode changes and the ProductVersion changes but the ProductCode remains the same. When I executed the Windows Installer on a system which had the previous version, it told me that I first had be installed without having to uninstall the previous version, but that is evidently not how Windows Installer works in this case. Is there any way of working with Windows Installer where
Windows Installer Doubts Windows 7 In windows Installer, i added one Custom Dialog called Textbox (A). It contains 4 Textboxes. I gave the can i achieve using VBScript Custom Action? I am working in C#. I am using Windows Installer and not Install Shield. So tell me is it a limitation in Windows Installer or not? If not give the solution. Regards C. Senthil Kumar. Platform SDK MSI