In part 1 I talked about some of the basics of setting up the installer and using icons and shortcuts. In this installment I'm going to go into some more advanced uses, especially for Windows 7 and Vista installations.
One of the things that changed with Vista/Win7 is that any files installed into the Program Files directory cannot be written to without running your program with administrator privileges. And as an aside one strange thing I've noticed about running with these privileges is that Microsoft Office Interop doesn't play nice with Outlook. Also, the current best practice is that you shouldn't be writing to files in the program files directory.
If you have .xml files, log files, office templates or attachments that you want to write to in your application, you too should take advantage of the LocalAppData folder. First, if you want to see this folder you need to show hidden folders. Then you can go to your user directory, open AppData, then drill down in the local folder. Mine has a lot of folders with GUID names at the top but after that I get the folders named after manufacturers who have installed programs on my computer.
Visual Studio Installer - Adding the Folder
In Visual Studio open the File System view of your installer project. Right-click on the topmost element in the left pane and open the Add Special Folder menu. From there select the User's Application Data Folder as shown in the image. I've already added it so that it shows as dimmed out in the image.
In the Properties pane for the File System you should see entries for Manufacturer and Product (see Part 1 for more details). You'll want to manually create some folders under LocalAppData based on those settings. In this example I have the manufacturer set to Syncor and the ProductName set to Hss Order Tracker.
Adding the Files to the Folder
Once you have the folder path created (you can see in the image I have a subfolder named Syncor and then one called HOTS) you can right click on the destination folder as shown and add output from your project to the folder.This will display the Add Project Output Group dialog. If you have multiple projects in your solution be sure to select the proper project in the upper right drop down list. Then choose the Content Files option as shown. The installer will put all the files marked as Content in the project HssOrderTracker into this local application data folder.
Making it Optional
When I'm doing early alpha releases I want to distribute a new installer but I don't want to keep wiping out changes the user made to any settings in the local application data. There is probably more than one way to do this but I used a custom dialog.
I've never really noticed the icons at the top of the Solution Explorer before but you can hover over each one to get a glimpse into its purpose. As you can see in the image, there is one that will bring up the User Interface Editor.
In the user interface dialog you can right click on any section and add Dialogs, I used the Start section. Once you've added it you can use the properties pane on the right to disable unneeded checkboxes, change the label, value, property and visibility of the checkbox. I change my BodyText property as well. The CheckBox1Property also became INSTALLFILES. I also deleted the useless Welcome screen.Then back in the File System Editor I selected the Content Files option and modified the Condition to be INSTALLFILES=1 as shown. While you're here, set the Permanent property to True. That tells the uninstaller to not delete these files when it uninstalls. Generally not something you want to do but if you don't your installer will delete the very files we didn't want to overwrite.
If you want to have your company's logo appear when the installer runs and you don't want to modify the default banner on every page you can follow the instructions on this blog. Since the banner and the banner text overlap I would suggest creating a logo of 500X70 but only using the rightmost 100 or so pixels for your logo. That way your logo and the banner text won't overlap.