views:

294

answers:

7

Can anyone list the steps needed to programatically install an application on Windows. Aside from copying the files where they need to be, what are the additional steps needed so that your app will be a first-class citizen in Windows (i.e. show up in the programs list, uninstall list...etc.)

I tried to google this, but had no luck.

BTW: This is for an unmanaged c++ application (developed in Qt), so I'd rather not involve the .net framework if I don't have to.

+4  A: 

I've used Inno Setup to package my software for C++. It's very simple compared to heavy duty solutions such at InstallShield. Everything can be contained in a single setup.exe without creating all these crazy batch scripts and so on.

Check it out here: http://www.jrsoftware.org/isinfo.php

Jeremy Edwards
While you're getting InnoSetup, make sure you get the GUI Inno Tools; it makes setting up the install script really easy, and can run the compiler to build the install without having to go to the command prompt.
Ken White
A: 

You've already got the main steps. One you left out is to install on the Start Menu and provide an option to create a desktop and/or quick launch icon.

I would encourage you to look into using a setup program, as suggested by Jeremy.

jdigital
+7  A: 

I highly recommend NSIS. Open Source, very active development, and it's hard to match/beat its extensibility.

To add your program to the Add/Remove Programs (or Programs and Features) list, add the following reg keys:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\PROGRAM_NAME]
"DisplayName"="PROGRAM_NAME"
"Publisher"="COMPANY_NAME"
"UninstallString"="PATH_TO_UNINSTALL_PROGRAM"
"DisplayIcon"="PATH_TO_ICON_FILE"
"DisplayVersion"="VERSION"
"InstallLocation"="PATH_TO_INSTALLATION_LOCATION"
Andrew
Why the down vote?
Troy J. Farrell
I dunno. Maybe someone hates NSIS.
Andrew
Maybe someone thought you didn't really answer the question, and instead spoke to only one example.
Rob Kennedy
@Rob: Maybe I'm reading your comment wrong, but it seems insulting. Maybe I didn't have the most complete answer, but I believe it was helpful and specifically addressed one of the points he mentioned with relevant code. It would seem the users of SO find my answer more helpful than yours anyway.
Andrew
+1  A: 

The GUI for innosetup (highly recommended) is Istool

You can also use the MSI installer built into Visual Studio, it's a steeper learning curve (ie is a pain) but is useful if you are installing software in a corporate environment.

Martin Beckett
+1  A: 

It sounds like you need to check out the Windows Installer system. If you need the nitty-gritty, see the official documentation. For news, read the installer team's blog. Finally, since you're a programmer, you probably want to build the installer as a programmer would. WiX 3.0 is my tool of choice - open source code, from Microsoft to boot. Start with this tutorial on WiX. It's good.

Troy J. Farrell
+1  A: 

To have your program show up in the Start program menu, You would need to create folder C:\Documents and Settings\All Users\Start Menu\Programs and added a short cut to the program you want to launch. (If you want your application be listed directly in the Start menu, or in the programs submenu, you would put your short cut in the respective directory)

To programically create a short cut you can use IShellLink (See MSDN article).

Since you want to uninstall, that gets a lot more involved because you don't want to simply go deleting DLLs or other common files without checking dependencies. I would recommend using a setup/installation generator, especially nowadays with Vista being so persnickety, it is getting rather complicated to roll your own installation if you need anything more than a single executable and a start menu shortcut.

I have been using Paquet Builder setup generator for several years now. (The registered version includes uninstall).

Roger Nelson
Although instead of using "C:\Documents and Settings\All Users\Start Menu\Programs" you should use an appropriate environment variable.
Max Lybbert
Right, more specifically use something like CSIDL_COMMON_PROGRAMS or CSIDL_PROGRAMS see: http://msdn.microsoft.com/en-us/library/bb762494.aspx
Roger Nelson
And that depending on whether you're running as admin, and if so if you're doing a admin-only or all-user install. But when writing an installer, the second task (after the file copy) should be to setup the Add/Remove Programs entry to clean up everything.
MSalters
+6  A: 

I think the theme to the answers you'll see here is that you should use an installation program and that you should not write the installer yourself. Use one of the many installer-makers, such as Inno Setup, InstallSheild, or anything else someone recommends.

If you try to write the installer yourself, you'll probably do it wrong. This isn't a slight against you personally. It's just that there are a lot of little details that an installer should consider, and a lot of things that can go wrong, and if you want to write the installer yourself, you're just going to have to get all those things right. That means lots of research and lots of testing on your part. Save yourself the trouble.

Besides copying files, installation tasks vary quite a bit depending on what your program needs. Maybe you need to put an icon on the Start menu; an installer tool should have a way to make that happen very easily, automatically filling in the install location that the customer chose earlier in the installation, and maybe even choosing the right local language for the shortcut's label.

You might need to create registry entries, such as for file associations or licensing. Your installer tool should already have an easy way to specify what keys and values to create or modify.

You might need to register a COM server. That's a common enough action that your installer tool probably has a way of specifying that as part of the post-file-copy operation.

If there are some actions that your chosen installer tool doesn't already provide for, the tool will probably offer a way to add custom actions, perhaps through a scripting language, or perhaps through linking external code from a DLL you would write that gets included with your installer. Custom actions might include downloading an update from a specific Web site, sending e-mail, or taking an inventory of what other products from your company are already installed.

A couple of final things that an installer tool should provide are ways to apply upgrades to an existing installation, and a way to uninstall the program, undoing all those installation tasks (deleting files, restoring backups, unregistering COM servers, etc.).

Rob Kennedy
Your answer seemed to sum up the gist of the rest of the posts. Thanks a lot!
JimDaniel