views:

199

answers:

2

Okay so I want to make an application that launches other applications. However, the goal here is to make the app "portable" in that I can go from one windows desktop to another while using the same application from a usb drive. So here is a different rundown of what I mean:

I have aplication X. I use it on machine 1 and I want to use it on machine 2. However, machine 2 is my buddy's and he does not want me installing things on it. So, I take all the files that the installer made on my system, and put them into folders. App X put files in the windows folder that it expects when it is launched. If I merely run the the app and it looks in the windows dir it will not find the files. I do not have/want the ability to put files in the windows dir. I want to tell the app to look in folder a for files in folder b instead of where it would normally look. I could then use this program on any machine without having to modify the machine in any way.

Is this doable? If so what is it called so I can look it up?

EDIT: the win dir was an example. I would like the app to be self contained in a folder on the thumb drive. I want to redirect the where the app looks for files to a folder I specify.

+3  A: 

This can be done, but how easily depends entirely on the program that you are launching.

The sorts of things that applications will do are:

  • Just run happily being executed anywhere (no dependencies). These are very easy!

  • Require some environment variables to be set up. This is easy to do - you can launch a new process with a modified environment if you wish.

  • Read files from disk. Usually when loading things like .dlls, applications will search on the PATH for the dlls, so they can be copied into the application folder (next to the .exe) and it will run happily on any system. However, in some cases applications will use fixed (or at least, less flexible) paths so that they will be harder to launch successfully.

  • Read registry settings. This is trickier. You need to know what state is required by the application, have your launcher record the old registry state, change it and run the application, then wait for application exit to restore the original state. This has to be bullet-proof to avoid corruption of the user's registry.

Ultimately you'll need to investigate, for each app you want to launch, just what it needs to run.

If the apps are commercial, then be careful that you are not breaking any licensing (EULA) terms by running them in this way.

Another alternative would be to set up a virtual PC image and simply execute that on the host PC so there is no need to worry about any special cases for each application. Depending on the VPC software you have available you may need to install software on the host PC to allow a virtual PC session to be run though, which may defeat the purpose/intent.

Jason Williams
Thank you. I am having trouble finding information on executing a process with a modified environment.
sobertillnoon
It depends on the language you're using. FOr example, from C++, use CreateProcess() to launch a process, passing in any environment variables you need in lpEnvironment. See http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx . In C#/VB use a System.Diagnostics.Process.Start, passing in a ProcessStartInfo (which includes the environment variables): http://msdn.microsoft.com/en-us/library/0w4h05yb.aspx
Jason Williams
And with lpEnvironment pram I can say in effect "%windir=c:\fakewindir"
sobertillnoon
You can, but it is unlikely that any applications will take any notice of that particular change. However, you can change things like PATH (the folders that are searched to load dlls) to add your own local folders in front of the default ones, and many applications provide their own custom environment variables (e.g. MAYA_PLUGIN_PATH from Autodesk Maya) that can be used to configure their behaviour. In many cases you will need to find out the specific hacks that are required for the individual application - this is not a universal solution by any means.
Jason Williams
+1  A: 

I think the system you describe is U3 (more info at http://en.wikipedia.org/wiki/U3). It requires the application to follow the U3 protocol, but if the application does, then it can be run off of a U3 flash drive without any install or admin permissions required on the host machine.

It's a proprietary technology, and supported by only a few vendors that I've seen.

If you really want portability and power, consider VMWare Player, and carry and entire machine, customized to your needs, on the flash drive. Of course, your friend would probably have to allow you to install VMWare Player.

Jason R. Coombs