You are here

need help (Setting Environmental Variables Temporarily )

8 posts / 0 new
Last post
habenyamin
Offline
Last seen: 3 years 2 months ago
Joined: 2009-02-06 13:04
need help (Setting Environmental Variables Temporarily )

Hi
I searched about it and also I found A lot of using script for Setting Environmental Variables Temporarily at site ( redirect folder)but I don't know why didn't work with Nsis launcher
also here
http://nsis.sourceforge.net/Setting_Environment_Variables

StrCpy "$SETTINGSDIRECTORY" "$EXEDIR\Data\${DEFAULTSETTINGSDIR}"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("APPDATA", "$SETTINGSDIRECTORY")
when run Nsis Launcher with this code Portable APP made setting in AppData
folder again (why didn't make Directly in the $SETTINGSDIRECTORY?)
any one can tell what is wrong?

Jimbo
Offline
Last seen: 5 years 3 months ago
Joined: 2007-12-17 05:43
What is the app?

There are (at least) three different ways that an application can query the location of the Application Data folder.

There is the %APPDATA% environment variable, there is a syscall to SHGetSpecialFolderLocation, and there is directly querying the registry.

Beyond that, some apps actually build the path to it based on the username.

Different application use different methods, so without knowing what the application you are trying to portablize is, there is no way of knowing which method it is using, and, therefore, no way to know why it isn't working.

The bad news is that there isn't any way (so far as I know) to redirect the syscall, a registry change is global to the entire machine while your app is running, and if the app is poorly written (builds the path itself) you're even more stuck.

If it is open source, you can look through the code to see what method it uses to determine its data folder, and, if necessary, you could even modify it, and submit patches to the author for consideration to assist with making it more portable.

If it is closed source, you could try contacting the author, but that can have variable success depending on the size of the organisation that wrote it.

habenyamin
Offline
Last seen: 3 years 2 months ago
Joined: 2009-02-06 13:04
good guide

it is close source.
I couldn't find any ini file or data from it to help .
need to contact to author.

thank u for your guide to me

qwertymodo
qwertymodo's picture
Offline
Last seen: 12 years 9 months ago
Joined: 2008-03-17 19:08
Also, redirecting AppData is

Also, redirecting AppData is usually not considered a good idea. Rather, you should just move the files before and after the app is run.

Quamquam omniam nescio, nec nihil scio.

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 10 months ago
Joined: 2007-04-15 21:08
Depends

If it can be done just with changing APPDATA - not USERPROFILE as well - then there's nothing wrong with it.

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

Simeon
Simeon's picture
Offline
Last seen: 10 years 6 months ago
DeveloperTranslator
Joined: 2006-09-25 15:15
?

I thought its the best way to do it because it only redirects the variable for the current process and its child processes.

"What about Love?" - "Overrated. Biochemically no different than eating large quantities of chocolate." - Al Pacino in The Devils Advocate

Jimbo
Offline
Last seen: 5 years 3 months ago
Joined: 2007-12-17 05:43
can still cause issues

for example, if those child processes include spawning the default browser, then it could try to launch the locally installed firefox pointing it's profile folder to some bizarre place on your flash drive, which is unlikely to be the desired or expected result.

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 10 months ago
Joined: 2007-04-15 21:08
APPDATA/USERPROFILE

Again, it depends on what you change. If you just change APPDATA, you should be fine. USERPROFILE shouldn't really be changed ever.

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

Log in or register to post comments