The methodology behind most of my scripts is...
1. Backup existing settings (rename/move)
2. Move portable settings files/registry into the original location
3. Launch portable app
4. Copy portable settings back to portable drive
5. Restore the backup files
This is a very effective system when dealing with settings and data which are (very) small because it can be done very quickly to the point where the end user doesn't even observe a delay. However, what happens when a program saves a 10mb settings file in the %AppData% folder? This is the problem I've been trying to deal with.
I've tried a million different approaches, including trying to link files, create virtual folders... etc. Nothing works! But now I've found the solution, and it's so obvious.
Here's an example (this is AutoIt code)
Code: Select all
$dir = @ScriptDir&'\Data\Settings'
EnvSet("ALLUSERSPROFILE", $dir)
EnvSet("APPDATA", $dir)
EnvSet("HOMEPATH", $dir)
EnvSet("USERPROFILE", $dir)
EnvSet("PROGRAMFILES", $dir) ;Not sure this is necessary
Run(@ScriptDir&'\App\example.exe')
It's a simple idea, but this means that I can now portablize programs which use AppData, My Documents, etc.