views:

283

answers:

2

Hi,

in our project we want to copy 2 files, which are not included in the *.msi file. Therefore i created a managed custom action which copies the files using File.Copy(). The files should be copied to my installation dir, which is somewhere under C:\Program Files\...

With Windows XP everything works fine. But in Windows 7 their is a problem with the UAC i guess:

Althought the log-file says the files are copied to the desired location (e.g. C:\Program Files\MyApp\") they are not there. Instead they are copied to something like "C:\Users\MyUser\AppData\Local\VirtualSotre\Programm Files (x86)\MyApp\". I guess this has something to do with missing priviliegs for modiving the program folder? Anyone an idea what to do?

This is how i call the custom action in wix:

    <CustomAction Id='InstallSource' BinaryKey='SrcInstActionDll' DllEntry='InstallSourceFiles' Execute='deferred' Impersonate='no'/>
   <CustomAction Id="InstallSource.SetProperty" Return="check" Property="InstallSource" Value='Files=[SourceDir]$(var.SourceZipName),[SourceDir]$(var.SymbolsZipName);TargetDir=[ParentFolder]' Execute='immediate'/>

The custom action itself doesn't do much more then calling File.Copy().

Other files which are copied during the installation process by the installer work perfectly with windows 7. Only the files which are copied using the custom action have the described problem.

Thanks Daniel

+1  A: 

Hi.

Indeed this behavior is caused by the file system redirection triggered when a 32 bit app (in a 64 bits Windows) running as an standard user tries to write to some privileged folder.

For me it looks like your custom action is not running elevated. Since the custom action definition looks correct the question that remains is where you are firing this custom action.

Since you mention the log I assume you are running msiexec and checking the logs. Make sure that your custom action runs after a line that looks like:

MSI (s) (BC:70) [13:34:10:669]: MSI_LUA: Elevation required to install product, will prompt for credentials
MSI (s) (BC:70) [13:34:59:528]: MSI_LUA: Credential Request return = 0x0
MSI (s) (BC:70) [13:34:59:528]: MSI_LUA: Elevated credential consent provided. Install will run elevated

Some time ago I had a similar issue with custom actions and this blog post helped me to figure out how to fix it. This is another post that I think may help

Hope this helps

Vagaus
A: 

Like you said, I think that your Custom Action needs elevation. Since your CA is a .Net project, it's kind of eassy to set it up to support elevation.

Please check the next link, it has a good explanation on how to handdle UAC on a .Net project.

enabling-your-application-for-uac-on-vista

Hope it helps.

Mario