The best way is to not write it yourself and use an existing installer generator. If you are under Windows, Visual Studio has the ability to generate MSI files, and there are tons of other software that will do it as well.
If you are under Linux, create a package (RPM or DEB, depending on which distribution you are targeting.