Hi!
I'm working on my first PortableApp which is using %APPDATA% folder for storing settings. Is it possible for the Launcher trick the app so that it could use Data/settings directory instead of %APPDATA% or should I recompile the application?
New: DesktopSnowOK (Jan 6, 2025), Platform 29.5.3 (Jun 27, 2024)
1,100+ portable packages, 1.1 billion downloads
No Ads Nov/Dec/Jan!, Please donate today
Hi!
I'm working on my first PortableApp which is using %APPDATA% folder for storing settings. Is it possible for the Launcher trick the app so that it could use Data/settings directory instead of %APPDATA% or should I recompile the application?
If it uses environment variable as you suggest, then it's easy. Just set %APPDATA% to your Data\settings.
If it uses shellapi to retrieve it's path then it is still possible, but significantly harder.
"Those people who think they know everything are a great annoyance to those of us who do." Asimov
my ultraMaGe Portable for a quick way to copy them back.
Insert original signature here with Greasemonkey Script.
I've seen this posted before in the forums:
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("APPDATA", "$SETTINGSDIRECTORY").r0'
Question to everyone else though: If you changed the appdata env variable, wouldn't that cause other programs to use your data/settings folder to store stuff while your launcher was running, or does this just affect the launched program?
Only the EXE you call and any other apps called from it.
APPDATA isn't used by most apps, though. Many get it from the registry or from USERPROFILE.
Sometimes, the impossible can become possible, if you're awesome!
Please search before posting. ~Thanks
Some posted changing the %AppData% environment variable to set it to the PortableApps' Data folder. I would strongly avoid redirecting things like that for the main reason that there could be more apps running at the same time possibly using the %AppData% while running a portable app, that would essencially redirect everything to the USB drive for all applications.
I myself use this approach:
Check if an PortableApps backup of the folder exists (if so, skip renaming any existing)
Rename existing folder to a backup name (Not the AppData folder itself ofcource! The subfolder inthere that the application uses)
copy folder from Data\Settings\ folder
start application
After exit, copy folder back to Data\Settings\
Delete the copied folder
Rename the original folder back to the old name
As stated previously, it doesn't work that way. When you set an environment variable using the code I've given in my launchers, it only affects the launcher and any other processes you launch from it. It does not affect outside apps.
But you need to take into account what apps your app may launch, which can cause issues.
Sometimes, the impossible can become possible, if you're awesome!
Ah, ok. I already got visions my whole system storing its data on \Data\Settings\
Generally he's wrong, but in some cases it's indeed important. If portable application can start a local one (i.e. file manager or command prompt), it definitely shouldn't change it's %APPDATA%.
"Those people who think they know everything are a great annoyance to those of us who do." Asimov
If the NSIS-Launcher redirects a system variable, only he and all its child-processes (processes launched by the launcher) use the redirected variable. All other Apps running at that time use the standard. So there is no way this could redirect everything to the USB drive.
"What about Love?" - "Overrated. Biochemically no different than eating large quantities of chocolate." - Al Pacino in The Devils Advocate
You need to understand the concept of "inheriting an environment", changing it, and passing on the new environment to processes you start.
On the other hand, I was appalled the other day to watch an Adobe Air application read the APPDATA environment variable I set for it and change the corresponding HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders value to match the environment. Now that would (did) affect other applications, and I consider it a bug.
I hope your apps don't do something like that.
MC
Nah, My apps do not change registry settings.