Newbie here,
I'm finalizing my U3 version, and figured I'd do PortableApps too. I'm not yet writing my script, but wanted to build the hooks into the main app first. With U3, I'm able to use Environment Strings to find path info, such as:
IShouldStoreMyDataHere := GetEnvironmentVariable('U3_APP_DATA_PATH');
Can I do this with NSIS? Or do I need it in conjunction with something else? Let me know if there is a sample app that does this. I looked through several, but maybe I didn't know what to look for.
I could pass as cmd-line params, but I'd rather do it the same way I'm doing it for U3.
Thanks,
Chris
Looks like I do this:
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("USERPROFILE", "$SETTINGSDIRECTORY").r0'
Signature automatically removed for containing links
It's better not to use the environment variables. Your best bet is to add in functions to your standard non-portable app to accept a command-line option of pointing it to a different data path. Something like:
myapp.exe --data-path="path_to_data"
Then, for your U3-specific package, you place your app binaries in the Device directory, your default data in the Data directory and you specify in your manifest file that it passes the path to your EXE. Something like this:
<appStart cmd="%U3_DEVICE_EXEC_PATH%\myapp.exe">--data-path="%U3_APP_DATA_PATH%"</appStart>
And, for your portable version, you create a small stub launcher in NSIS, C++, or your language of choice that just calls the app with the correct path. So, for the package, you'd place your EXEs in an MyAppPortable\App\MyApp directory, your data files would be in MyAppPortable\Data and you'd place a stub launcher called MyAppPortable.exe within the MyAppPortable directory. In NSIS, what I code my launchers in, the code to accomplish this is just a single line:
Exec `$EXEDIR\App\MyApp\myapp.exe --data-path="$EXEDIR\Data"`
Then as you're working on your app going forward, you don't have to worry about mucking with any U3-specific code in your base app since it's all handled.
Sometimes, the impossible can become possible, if you're awesome!
It's better not to use the environment variables.
They have some disadvantages. But they are a really good way to improve integration of one's portable applications. Which makes configuration easier (when I have my gcc in %PATH%, I can just write "gcc" in compilers path in 95% of programmers' text editors.). And removes redundancy (Using the same dlls or the same scripts with various applications.).
"Those people who think they know everything are a great annoyance to those of us who do." Asimov
The path variable isn't what we're talking about. We're talking about whether it's a good idea to actually alter your code to specifically check the U3-specific environment variables. And I suggested not doing it and doing it in the U3 manifest instead.
Sometimes, the impossible can become possible, if you're awesome!