Have you ever wanted to take your favorite applications, as well as their settings, and be able to use them on any computer? Have you ever wanted to be able to reinstall Windows without having to reinstall and reconfigure all your programs? Have you ever wanted to demonstrate a new app to a friend without installing it first?
If you have answered "yes" to any of the previous questions, then you are looking for portable applications. They do not depend on the computer they are running on, and can be easily shared with anyone. They are your computer on any computer.
Do you have an application you want to make portable? We'll see how to do it. But first, there are a few things we have to learn, like the full definition of portable application.
What is a portable application?
"An application can be considered portable when it can be moved between computers without loss of personal settings or functional features."
This means that you can plug you external drive on any computer, launch your portable word processor, and all your preferences are there, untouched. You then decide to listen some music, open you portable music player, and voilá, your library and playlists are there. Your portable browser also keeps all your preferences, bookmarks and themes, and all your extensions are still working. But the most important is, you can move to another computer and you will get the same results.
"It also must not leave traces of its execution on the host, except by those generated automatically by the operating system."
It would not be nice if your portable browser left all your personal browsing data fully available for other persons to see, would it? After finishing execution, a portable applications will not leave its settings all over the host; everything is contained alongside the own application.
"Furthermore, any paths used by the application (e.g. external applications, recently used files etc.) must stay working when the drive letter of the drive where it is installed changes, like when switching computers."
The Recent Files list of your portable text editor will stay working for any files stored in the same drive as the application.
"When possible, the application should also support being moved to a different directory."
If you are reorganizing your external drive for the Nth time, you should be able to move all your portable applications to any folders you wish, except when otherwise indicated.
Application portablization techniques
Most applications are not designed to be portable or are only partially portable. In these cases, there are several techniques that can be used in order to make an application fully portable.
The simplest one is application virtualization, in which the application is run in top of another program, that intercepts changes to the registry and file system and redirects them to another location. This method is the simplest because most of time it is possible to use already existing software to perform the virtualization, like VMware ThinApp. This method, though, has some problems: the majority of virtualization softwares are quite expensive, and are also incompatible with some software licenses, like the GNU GPL; some of them also impose strict limitations on what the user can do with the virtulized software.
Another possibility is the use of a wrapper, a small program that handles the portablization of the base application. The changes the application can do on the file system and on the registry are analysed and then the information gathered is used to build a program that saves and neutralizes those changes. A wrapper can be developed using any programming language that supports the Windows API, including plain batch files.
The most advanced way is to modify the source code of the base application. However, this method has various drawbacks: first, it can only be used with open source applications; second, once implemented, every change to the base application needs to be fully portable; and third, it is almost impossible to make most applications fully portable this way, as it would require e.g. storing all paths as relative to the application's directory, but then, what if the application is moved?
Because of the problems of the application virtualization and source code modification approaches, it is always advisable to use a wrapper, even in conjunction with the other ones.