Discussion:
[WiX-users] installing files to user's application data folder
michaelrepucci
2010-08-05 16:37:17 UTC
Permalink
I'm a complete newbie to WiX and Windows Installer. I've worked through the
tutorials and documentation, and feel pretty comfortable with all the
basics. Now I'm trying to create an installer to fit my requirements, and
while the basic install of the app and shortcuts, including conditions, and
custom UI, works just fine, I'm struggling with a special requirement.

What I have is an app that can run standalone, or can act as an add-on to a
3rd-party software package. I can install the app just fine, but in order to
add a reference to my app on the toolbar of the 3rd-party software, I need
to install some XML files to the user's %Application Data% folder. I started
with:

<Directory Id="AppDataFolder">
<Directory Id="3rdPartyAppData" Name="3rdParty">
<Directory Id="3rdPartyAppDataSubfolder" Name="Subfolder">
<Component Id="3rdPartyToolbar" Guid="PUT-GUID-HERE">
<File Id="Toolbar" Name="an.xml" Source="the.xml" DiskId="1"
KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Directory>

but I get an ICE38 error that says I can't use the file as the KeyPath. I
don't understand why that's the case, since I can use my app's file as the
KeyPath in the primary component (not shown). I tried searching online for
this issue, but all I found were people placing shortcuts into the user's
profile, not files. Perhaps I'm installing this file in a non-standard
manner. Is there another recommended way to do this? In a similar manner as
for shortcuts - but what I feel is a hack in this situation - I can add a
registry value to the Component tag as the KeyPath to prevent this error.

However, I also get a couple ICE64 errors about these user profile
directories not being in the RemoveFile table. I thought I'd solve those
issue by adding the following within the Component tag:

<RemoveFolder Id="3rdPartyAppDataSubfolder" On="uninstall" />
<RemoveFolder Id="3rdPartyAppData" On="uninstall" />

but it doesn't seem to notice these entries. Where do I have to place them?
BTW, these directories may or may not exist, depending on whether the user
has other add-ons installed for this 3rd-party software. So I wouldn't
necessarily want the RemoveFolder tag to remove the folder, but to do so
only if my installer had to create the directories. I assume this is the
default behavior, but please let me know if it is not.

Thank you in advance for your help!
--
View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/installing-files-to-user-s-application-data-folder-tp5377311p5377311.html
Sent from the wix-users mailing list archive at Nabble.com.
Chris Lord
2010-08-05 17:17:18 UTC
Permalink
Michael,

With only one file in the component, you probably don't need the
KeyPath. My WXS doesn't need the KeyPath for a file (I have a single
file in each component) and it passes all ICE tests.

As far as putting files into a specific user folder that should be OK if
you are doing a per-user install. I suspect though that you are not and
are doing a per-machine install instead in which case placing files in a
specific users folder is fraught with problems and hence the warning.
For example, what if another user tries to uninstall you application?
They won't be able to access the file as its in another users files and
thus the installer can't remove it and leaving files behind is
considered bad installation design. If you are doing a per-machine
install, then you should place the file into a common folder rather than
a specific user folder.

Chris
Post by michaelrepucci
I'm a complete newbie to WiX and Windows Installer. I've worked through the
tutorials and documentation, and feel pretty comfortable with all the
basics. Now I'm trying to create an installer to fit my requirements, and
while the basic install of the app and shortcuts, including conditions, and
custom UI, works just fine, I'm struggling with a special requirement.
What I have is an app that can run standalone, or can act as an add-on to a
3rd-party software package. I can install the app just fine, but in order to
add a reference to my app on the toolbar of the 3rd-party software, I need
to install some XML files to the user's %Application Data% folder. I started
<Directory Id="AppDataFolder">
<Directory Id="3rdPartyAppData" Name="3rdParty">
<Directory Id="3rdPartyAppDataSubfolder" Name="Subfolder">
<Component Id="3rdPartyToolbar" Guid="PUT-GUID-HERE">
<File Id="Toolbar" Name="an.xml" Source="the.xml" DiskId="1"
KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Directory>
but I get an ICE38 error that says I can't use the file as the KeyPath. I
don't understand why that's the case, since I can use my app's file as the
KeyPath in the primary component (not shown). I tried searching online for
this issue, but all I found were people placing shortcuts into the user's
profile, not files. Perhaps I'm installing this file in a non-standard
manner. Is there another recommended way to do this? In a similar manner as
for shortcuts - but what I feel is a hack in this situation - I can add a
registry value to the Component tag as the KeyPath to prevent this error.
However, I also get a couple ICE64 errors about these user profile
directories not being in the RemoveFile table. I thought I'd solve those
<RemoveFolder Id="3rdPartyAppDataSubfolder" On="uninstall" />
<RemoveFolder Id="3rdPartyAppData" On="uninstall" />
but it doesn't seem to notice these entries. Where do I have to place them?
BTW, these directories may or may not exist, depending on whether the user
has other add-ons installed for this 3rd-party software. So I wouldn't
necessarily want the RemoveFolder tag to remove the folder, but to do so
only if my installer had to create the directories. I assume this is the
default behavior, but please let me know if it is not.
Thank you in advance for your help!
michaelrepucci
2010-08-05 18:08:30 UTC
Permalink
Post by Chris Lord
With only one file in the component, you probably don't need the
KeyPath. My WXS doesn't need the KeyPath for a file (I have a single
file in each component) and it passes all ICE tests.
I would have thought so, but I get the same ICE38 error. Based on the MSDN
documentation -
http://msdn.microsoft.com/en-us/library/aa368961%28VS.85%29.aspx - the
registry key is required for any file placed in the user's profile. I
suppose it's not worth asking why this is the case; I should just accept
that's how it is. But it threw up a red flag for me that perhaps I wasn't
putting files into the AppDataFolder in the correct or recommended way.
Post by Chris Lord
As far as putting files into a specific user folder that should be OK if
you are doing a per-user install. I suspect though that you are not and
are doing a per-machine install instead in which case placing files in a
specific users folder is fraught with problems and hence the warning.
I guess I must admit that I'm not sure what I'm doing. I thought (assumed)
that I was doing a per-user install (that's my intention), but honestly
don't know how to switch from per-user to per-machine or vice versa. I don't
recall learning this from the tutorials, so any tips would be much
appreciated. Thanks!
--
View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/installing-files-to-user-s-application-data-folder-tp5377311p5377658.html
Sent from the wix-users mailing list archive at Nabble.com.
michaelrepucci
2010-08-05 18:31:54 UTC
Permalink
I did find a work-around for the ICE64 errors, but it seems a bit clunky (see
below). Can anybody confirm whether this is the correct way to do this?

<Directory Id="AppDataFolder">
<Directory Id="3rdPartyAppData" Name="3rdParty">
<Component Id="3rdPartyAppDataFolder" Guid="PUT-GUID-HERE">
<RemoveFolder Id="3rdPartyAppData" On="uninstall" />
</Component>
<Directory Id="3rdPartyAppDataSubfolder" Name="Subfolder">
<Component Id="3rdPartyToolbar"
Guid="PUT-GUID-HERE">
<File Id="Toolbar" Name="an.xml"
Source="the.xml" DiskId="1" KeyPath="yes" />
<RemoveFolder Id="3rdPartyAppDataSubfolder"
On="uninstall" />
</Component>
</Directory>
</Directory>
</Directory>
--
View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/installing-files-to-user-s-application-data-folder-tp5377311p5377739.html
Sent from the wix-users mailing list archive at Nabble.com.
michaelrepucci
2010-08-05 18:34:34 UTC
Permalink
Oh, my bad. I forgot the

<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]"
Type="string" Value="" KeyPath="yes" />

that belongs in each component. Still not an elegant solution, so comments
welcome. Thanks!
--
View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/installing-files-to-user-s-application-data-folder-tp5377311p5377751.html
Sent from the wix-users mailing list archive at Nabble.com.
Pally Sandher
2010-08-06 11:02:24 UTC
Permalink
That looks OK if it's passing the ICE tests now as it's much like the
sample in the How to create a shortcut
(http://wix.sourceforge.net/manual-wix3/create_start_menu_shortcut.htm).
Shortcuts are still files as far as the file system is concerned so
copying that sample for your own needs should be fine.

My only question would be do you need to use AppDataFolder as it's a
user-specific directory? If you're doing a per-machine installation does
the app your software is an add-on for allow you to use
CommonAppDataFolder instead? Also AppDataFolder is the Roaming folder
(http://msdn.microsoft.com/en-us/library/aa367565.aspx) are you sure you
shouldn't be using LocalAppDataFolder
(http://msdn.microsoft.com/en-us/library/aa369768.aspx) instead if you
have to use a user-specific directory?

Palbinder Sandher
Software Deployment & IT Administrator
T: +44 (0) 141 945 8500
F: +44 (0) 141 945 8501

http://www.iesve.com
**Design, Simulate + Innovate with the <Virtual Environment>**
Integrated Environmental Solutions Limited. Registered in Scotland No.
SC151456
Registered Office - Helix Building, West Of Scotland Science Park,
Glasgow G20 0SP
Email Disclaimer

-----Original Message-----
From: michaelrepucci [mailto:***@repucci.org]
Sent: 05 August 2010 19:35
To: wix-***@lists.sourceforge.net
Subject: Re: [WiX-users] installing files to user's application data
folder


Oh, my bad. I forgot the

<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]"
Type="string" Value="" KeyPath="yes" />

that belongs in each component. Still not an elegant solution, so
comments welcome. Thanks!
--
View this message in context:
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/installing
-files-to-user-s-application-data-folder-tp5377311p5377751.html
Sent from the wix-users mailing list archive at Nabble.com.

------------------------------------------------------------------------
------
The Palm PDK Hot Apps Program offers developers who use the Plug-In
Development Kit to bring their C/C++ apps to Palm for a share of $1
Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
michaelrepucci
2010-08-06 18:27:06 UTC
Permalink
Post by Pally Sandher
That looks OK if it's passing the ICE tests now as it's much like the
sample in the How to create a shortcut
(http://wix.sourceforge.net/manual-wix3/create_start_menu_shortcut.htm).
Shortcuts are still files as far as the file system is concerned so
copying that sample for your own needs should be fine.
The only lingering reason that I don't like this method, is that I have to
create additional empty components to remove the layers of subdirectories (3
deep in places). Fortunately, they don't get removed if there's other stuff
in there, so it just looks sloppy in the WiX file, nowhere else.
Post by Pally Sandher
My only question would be do you need to use AppDataFolder as it's a
user-specific directory? If you're doing a per-machine installation does
the app your software is an add-on for allow you to use
CommonAppDataFolder instead? Also AppDataFolder is the Roaming folder
(http://msdn.microsoft.com/en-us/library/aa367565.aspx) are you sure you
shouldn't be using LocalAppDataFolder
(http://msdn.microsoft.com/en-us/library/aa369768.aspx) instead if you
have to use a user-specific directory?
For various reasons, we need a per-user install. If I understand correctly,
that's the default when you don't explicitly set the ALLUSERS property in
WiX. At the very least, setting it explicitly to the empty string,
http://msdn.microsoft.com/en-us/library/aa367559%28VS.85%29.aspx as
specified on MSDN , doesn't compile (error CNDL0006) and instructs you to
remove the attribute, which I assume is equivalent to removing the whole tag
altogether. Please correct me if I'm wrong.

And, yes, we're installing to AppDataFolder, not LocalAppDataFolder. That's
where the 3rd-party software expects the add-on component XML files.
Incidentally, this 3rd-party software only runs on XP (don't get me
started), so that's our target as well.
--
View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/installing-files-to-user-s-application-data-folder-tp5377311p5381665.html
Sent from the wix-users mailing list archive at Nabble.com.
Continue reading on narkive:
Loading...