JimDaniel
JimDaniel

Reputation: 12703

how-to: programmatic install on windows?

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.

Upvotes: 5

Views: 1071

Answers (7)

Rob Kennedy
Rob Kennedy

Reputation: 163277

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.).

Upvotes: 7

Roger Nelson
Roger Nelson

Reputation: 1912

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).

Upvotes: 1

Troy J. Farrell
Troy J. Farrell

Reputation: 1252

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.

Upvotes: 2

Martin Beckett
Martin Beckett

Reputation: 96109

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.

Upvotes: 1

Andrew Ensley
Andrew Ensley

Reputation: 11697

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"

Upvotes: 10

jdigital
jdigital

Reputation: 12276

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.

Upvotes: 0

Jeremy Edwards
Jeremy Edwards

Reputation: 14740

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

Upvotes: 5

Related Questions