Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CustomAction help

12 views
Skip to first unread message

Micus

unread,
Nov 13, 2009, 3:53:49 PM11/13/09
to
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've 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

Wilson, Phil

unread,
Nov 13, 2009, 5:56:27 PM11/13/09
to
" I've found that with Vista, any registry modifications have to be done in
the Commit phase, not the Install phase, of installation."

I think you're 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 can't do those
things requiring higher privilege.

--
Phil Wilson
The Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972


"Micus" <No...@nowhere.com> wrote in message
news:uRTfRNKZ...@TK2MSFTNGP02.phx.gbl...

Micus

unread,
Nov 13, 2009, 6:44:44 PM11/13/09
to
Thank you for your response. My misunderstanding of the msi tech is not a
surprise, but I'm 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

"Wilson, Phil" <ph...@wonderware.nospam.com> wrote in message
news:9F5E70C6-9AFB-42E4...@microsoft.com...

Kalle Olavi Niemitalo

unread,
Nov 14, 2009, 7:22:24 AM11/14/09
to
"Micus" <No...@nowhere.com> writes:

> 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.

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

unread,
Nov 14, 2009, 2:23:16 PM11/14/09
to
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" <No...@nowhere.com> wrote in message

news:%23qyfysL...@TK2MSFTNGP04.phx.gbl...

Micus

unread,
Nov 14, 2009, 3:37:33 PM11/14/09
to
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've read, the 2008 c++ compiler does not target Win98-WinME
OS's for non .NET applications.

Also, after creating some installation packages, I've 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


"Phil Wilson" <pdjw...@nospam.cox.net> wrote in message
news:eXXjc$VZKHA...@TK2MSFTNGP02.phx.gbl...

Phil Wilson

unread,
Nov 15, 2009, 3:32:35 PM11/15/09
to
", the 2008 c++ compiler does not target Win98-WinME OS's for non .NET
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'd 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" <No...@nowhere.com> wrote in message

news:OEKs1oWZ...@TK2MSFTNGP06.phx.gbl...

Micus

unread,
Nov 16, 2009, 3:10:57 PM11/16/09
to
I'm 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'm 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

"Phil Wilson" <pdjw...@nospam.cox.net> wrote in message

news:uKqA1KjZ...@TK2MSFTNGP06.phx.gbl...

Wilson, Phil

unread,
Nov 16, 2009, 5:55:33 PM11/16/09
to
Where does the key come from? If it's in an installer property than you can
just write it to the registry using the setup's Registry IDE in the same
whay you'd 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


"Micus" <No...@nowhere.com> wrote in message

news:edqBRjvZ...@TK2MSFTNGP02.phx.gbl...

MikeMio

unread,
Nov 19, 2009, 11:12:01 PM11/19/09
to
>>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?

If I recall correctly (it's 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

Richard [Microsoft Windows Installer MVP]

unread,
Nov 20, 2009, 5:27:19 PM11/20/09
to
[Please do not mail me a copy of your followup]

"Micus" <No...@nowhere.com> spake the secret code
<uRTfRNKZ...@TK2MSFTNGP02.phx.gbl> thusly:

> 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 main thing you're 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're attempting to write and it avoids all the
impersonation issues you're bumping into.

However, VS.NET deployment projects don't 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.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/>

Legalize Adulthood! <http://legalizeadulthood.wordpress.com>

MikeMio

unread,
Nov 26, 2009, 12:21:01 PM11/26/09
to
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

"MikeMio" wrote:
> ...creating the msi file, you have to manually adjust the custom

> action type by turning on bit 12 (i.e. adding 0x800).
>

0 new messages