What to use to build an installer using Delphi 7?

(NOTE: Added 'important edit' below to basically re-ask this question in a different way)

I know there are many different packages out there to put inside a delphi application for software intallation. I don't need anything fancy, I just need the ability to do some of the basic installation routines, such as proper installation/replacement of DLL's. I can do the majority of the installation manually, like copying files, saving registry settings, etc. I just need whatever it takes to make my installer properly register the new software with Windows (or updated software).

It would also be helpful if it can, for example, check if a file is currently being used before trying to replace it. Nothing visual is needed, there must be some sort of simple non-visual component which can handle these common routines. And it should also be free open-source, if possible. I don't want to have to distribute a load of DLL's or other third-party files with my installer.

Any good suggestions? Please don't answer with any huge complex fancy installer system. It just needs to be something simple to use directly in Delphi. It doesn't even have to be a component, even just a unit or library of units with some functions or such to help automate these common bits and pieces of installation.

ADDED NOTE: I already have an installer program made in delphi-7, but would like something I can throw in my project which includes any type of assistance with the most common parts of installing software.


IMPORTANT EDIT:

My approach in asking this question I believe is wrong. Please allow me to re-elaborate on this...

Our company already has a simple updater utility. Actually, this is not an 'Installer', but an 'Updater' program. it simply replaces a few EXE files, executes SQL statements (MSSQL server), writes some registry entries, etc...

These are the issues I face with how this program is currently working:

  • Upon attempting to replace a DLL, the DLL might be in use, and therefore 90% of the time fails to replace the DLL. I need something that can check if the DLL is in use and (if possible) either forcefully replace the DLL anyway, or tell Windows to replace the DLL on the next restart.
  • The EXE name is 'Setup.exe' which Windows 7 automatically recognizes it as an installer (and thinks that it failed to install). I know there are workarounds for this, in fact, I saw a question here at stackoverflow recently for this exact case. I'd like to see if there's already something ready with whatever it is I get which can take care of this, instead of me doing the work manually.
  • This is a server/client system I'm working with. IF the installation is on the server, it also needs to update (replace) the service EXE. I know how to start/stop services, but have a lot of difficulties in waiting for the service to stop, then replace the file, then start it again. I'd like to see if this can be automated.
  • Executing a large SQL script (I mean over 25,000 lines in this script) is hell, and doesn't work half the time. It includes many instances of 'GO' which cannot be recognized by standard components, such as ADO. I can use a batch file to execute this, but that's getting a little dirtier than I'm comfortable with. There must be a way to execute such a script without the use of batch files - especially reading the result and trying to identify if there were any errors in the update.
  • This updater is also going to install another third-party installation, specifically SQL Native Client Drivers. I'd like something that is already ready to launch another installer and wait for the result of it (success or failure). If it fails, I need to know to continue the updater differently.

I can understand how it's difficult to understand what I'm asking for. I don't need a solution that can be used for anything and everything thrown at it. This is for this one software, nothing else. I know there probably isn't one single solution to cover all of the above, but any help would be great.

Answers


The JCL library includes a lot of the low level Windows functionality that you require. Most anything that can be done through the Windows API is available in JCL.

Refer to the previous question about what you need to do to prevent the "This program might not have installed correctly" message.

I scripted a similar database updater in the past that included many Go statements, for a MS SQL database. I used a VB script. That might not be a huge improvement over what you have now, but it did include flow control and trap errors. You can link to Windows Script Host in Delphi, but my main point is to figure out what interfaces are exposed by your DBMS and use them.

Here's a tip regarding DLLs. Don't put them in the Windows system folder. Put them in the same folder as the executable. This prevents other people from sharing your DLLs. That way, when your program is shut down, the DLLs are not loaded and you can replace them. If you're using shared system DLLs, then there's no workaround to rebooting.

If this updater is for the public, don't forget to sign it and put in the application manifest, so the users have a good experience.

I recommend tackling one issue at a time, and unless your application welcomes test units, write a small program to test each solution.

Other than that, I say go in elbows deep and start writing code.


While it's not a component, I'm posting this anyway. (Trying to do the work of an installer manually when there are great alternatives is a waste of your time, IMO, but feel free to vote this answer down if you find it unacceptable.)

InnoSetup is very well done, and (bonus) is written in Delphi and has source available. It does everything you can wish for in an installer (except create .msi files, which some large network admins require - this won't affect you, since you're willing to write most of your installation code yourself).

You'll want to get the IsTool GUI interface (available from the downloads page), which makes it much easier to configure the install scripts.

Another bonus: You can extend it using it's Pascal Scripting functionality.


Here are some answers to your large list of questions:

Upon attempting to replace a DLL, the DLL might be in use, and therefore 90% of the time fails to replace the DLL. I need something that can check if the DLL is in use and (if possible) either forcefully replace the DLL anyway, or tell Windows to replace the DLL on the next restart.

Call MoveFileEx passing MOVEFILE_DELAY_UNTIL_REBOOT.

The EXE name is 'Setup.exe' which Windows 7 automatically recognizes it as an installer (and thinks that it failed to install). I know there are workarounds for this, in fact, I saw a question here at stackoverflow recently for this exact case. I'd like to see if there's already something ready with whatever it is I get which can take care of this, instead of me doing the work manually.

Add an application manifest to your setup.exe program. This was indeed discussed here recently: How do I get my Installer Application to behave correctly with Windows?

This is a server/client system I'm working with. IF the installation is on the server, it also needs to update (replace) the service EXE. I know how to start/stop services, but have a lot of difficulties in waiting for the service to stop, then replace the file, then start it again. I'd like to see if this can be automated.

All the standard ways I know to stop a service wait until it has stopped running.

Executing a large SQL script (I mean over 25,000 lines in this script) is hell, and doesn't work half the time. It includes many instances of 'GO' which cannot be recognized by standard components, such as ADO. I can use a batch file to execute this, but that's getting a little dirtier than I'm comfortable with. There must be a way to execute such a script without the use of batch files - especially reading the result and trying to identify if there were any errors in the update.

This updater is also going to install another third-party installation, specifically SQL Native Client Drivers. I'd like something that is already ready to launch another installer and wait for the result of it (success or failure). If it fails, I need to know to continue the updater differently.

I regard these points as being too generic to give advice on.


All of these issues would be trivial with the help of a good third party install program like InnoSetup. I can't understand why you are reluctant to avail yourself of such a useful helping hand.


Need Your Help

Changing display value with CSS '+' operator

html css

I'm trying to create a dropdown menu using CSS, it's centered around using the following:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.