Most of my stuff gets deployed on the server side where the only users are
admins and support staff. I usually point them to the config XML files in my
documentation, but it is always useful to have a shortcut in the Programs
Menu folder (it also minimizes documentation). Another nice functionality is
to be able to associate a file with a default application; for example a
*.config file gets associated with notepad.exe in my case. The WIX tutorial
covers this possibility [of associating files with an application that is
part of the current MSI], but leaves us wanting more.
I was also able to incorporate Rob's tip on including an uninstall shortcut
for the application in the Programs Menu folder (I thought it would be nice
to point out this functionality on the forum since I had some hard time
finding Rob's original post - maybe I need to upgrade my Google'in skills).
Since I wasn't able to find any posts regarding this functionality, I
thought it would be nice to make a post with both these minor enhancements.
Requirement
1) Create shortcuts for the user in the Programs Menu folder that point to
the Application Configuration file and allows the user to uninstall the
product.
2) Associate the Application Configuration file with notepad.exe so that
when the users open it, it opens in Notepad by default (you can generalize
this feature and use it however you please)
Solution
Start off by declaring a Property that will search for notepad.exe. We will
use this property at a later stage to associate the .config file with
Notepad.
<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
<Product Name='FooBar 1.0' Id='YOUR-GUID' Language='1033' Codepage='1252'
Version='1.0.0.0' Manufacturer='Scrooge McDuck, Inc.'
UpgradeCode='YOUR-GUID'>
<Package Id='????????-????-????-????-????????????' Keywords='Installer' />
<Media Id='1' Cabinet='FDLEArchive.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1
" />
<Property Id='NOTEPADEXE'>
<DirectorySearch Id='NotePadContainer' Path='[SystemFolder]' Depth='0'>
<FileSearch Id='NotepadFile' Name='notepad.exe'/>
</DirectorySearch>
</Property>
Now we create the Programs hierarchy as usual and then reference the
'NOTEPAD' property in our 'Verb' element (highlighted yellow). Also note
that the same file is being added as a shortcut and it references the
'ShortcutFolder' (highlighted pink, or salmon for the sharp-eyed).
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='SMFolder' Name='Scrooge' LongName='Quack
Company'>
<Directory Id='INSTALLDIR' Name='Files' LongName='Folder
With Files'>
<Component Id='AppCONFIG' Guid='YOUR-GUID' DiskId='1'>
<File Id='AppConfigFile' Name='App.cfg' LongName
='MyFile.exe.config'
Source='MyFile.exe.config' Vital='yes'>
<Shortcut Id='ConfigEXEShortcut' Name='
ConfEXE.cfg'
Directory='ShortcutFolder'
LongName='Application Configuration File'
Description='Lets you configure settings
for the McDuck Utility.' />
</File>
<ProgId Id='XMLApp' Description='XML
Configuration File'>
<Extension Id='config'
ContentType='application/config'>
<Verb Id='Open' Sequence='10'
Command='Open' Argument='"%1"' Target='[NOTEPADEXE]'/>
</Extension>
</ProgId>
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
Now we create the Programs Menu hierarchy. Notice that the Directory Id is
'ShortcutFolder'. Later on, the uninstaller shortcut also refers to this
same Id. THIS SECTION IS COMPLETE RIP-OFF FROM ROB'S ORIGINAL POST. I lost
the link to Rob's original blog post, but maybe Rob can reply with the link
to his original post - he had some nice points about why he is using
System64Folder. I am pretty sure it is on his web site somewhere.
<Directory Id="ProgramMenuFolder"
Name="PMFolder" >
<Directory Id='ShortcutFolder' Name='MP' LongName='My Product
1.0'>
<Component Id='Shortcuts' Guid='YOUR-GUID' >
<Registry Root="HKCU" Key="SOFTWARE\My
Company\ProductName"
Type="string" KeyPath="yes" Value="Uninstall" />
<Shortcut Id="UninstallProduct" Name="unin.msi" LongName
="Uninstall My Product 1.0"
Target="[System64Folder]msiexec.exe" Arguments
="/x [ProductCode]"
Directory="ShortcutFolder"
Description="Uninstalls
My Product 1.0." />
<RemoveFolder Id="RemoveShortcuts" On="uninstall" />
</Component>
</Directory>
</Directory>
That is it! I hope this helps all the newbies (like myself) out there. If
you were to install an app using this fragment, you'd notice that a shortcut
is added to your config file and it gets associated to Notepad by default
(no more crappy documentation explaining users how to open a freaking XML
file... hehe).
If anyone would like to point out any improvements, please feel free to do
so!
By the way, ignore most of the ID elements, Long Name elements, etc., - I
named most of the elements and IDs randomly while I was posting. Also, folks
without HTML inboxes won't be able to see the highlights and colors I used!
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users