You are here

Settings stored in %APPDATA% problem

13 posts / 0 new
Last post
RaYell
Offline
Last seen: 15 years 7 months ago
Joined: 2007-05-08 07:53
Settings stored in %APPDATA% problem

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?

m2
Offline
Last seen: 13 years 1 month ago
Joined: 2006-12-12 12:00
If it uses environment

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

digitxp
digitxp's picture
Offline
Last seen: 12 years 6 months ago
Joined: 2007-11-03 18:33
You can also check

my ultraMaGe Portable for a quick way to copy them back.

Insert original signature here with Greasemonkey Script.

Travis Carrico
Offline
Last seen: 15 years 3 months ago
Developer
Joined: 2006-10-22 00:30
I've seen this posted before

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?

John T. Haller
John T. Haller's picture
Offline
Last seen: 5 hours 37 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
In Process

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!

powerjuce
powerjuce's picture
Offline
Last seen: 13 years 1 month ago
Developer
Joined: 2007-09-20 21:34
here is the code if you need it...
Var SETTINGSDIRECTORY
StrCpy $SETTINGSDIRECTORY "$EXEDIR\Data"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("APPDATA", "$SETTINGSDIRECTORY").r0'

Please search before posting. ~Thanks

LOGAN-Portable
LOGAN-Portable's picture
Offline
Last seen: 11 years 2 months ago
Developer
Joined: 2007-09-11 12:24
Some posted changing the

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

John T. Haller
John T. Haller's picture
Offline
Last seen: 5 hours 37 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Doesn't Work That Way

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!

LOGAN-Portable
LOGAN-Portable's picture
Offline
Last seen: 11 years 2 months ago
Developer
Joined: 2007-09-11 12:24
Ah, ok. I already got

Ah, ok. I already got visions my whole system storing its data on \Data\Settings\

m2
Offline
Last seen: 13 years 1 month ago
Joined: 2006-12-12 12:00
Generally he's wrong, but in

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

Simeon
Simeon's picture
Offline
Last seen: 9 years 5 months ago
DeveloperTranslator
Joined: 2006-09-25 15:15
nope

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

rab040ma
Offline
Last seen: 4 months 3 weeks ago
Joined: 2007-08-27 13:35
You need to understand the

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

LOGAN-Portable
LOGAN-Portable's picture
Offline
Last seen: 11 years 2 months ago
Developer
Joined: 2007-09-11 12:24
Nah, My apps do not change

Nah, My apps do not change registry settings.

Log in or register to post comments