Gluxon looked at the code and we both are getting errors. I'm going going to post on the HandBrake forum and see what I can find out what to do about the errors. If I cant figure out what to do I have two other choices I can do to make it work Move the folders in appdata (I rather not do that in case the computer get turned off or the usb gets unplugged ) Or I can make a patch for HandBrake to make it portable.
I just checked the Firefox launcher and it doesn't redirect APPDATA at all - it backs up, then restores, FF's APPDATA folder.
You can probably adapt my TopOCR launcher to handle this; just change the backup & restore locations.
"The question I would like to know, is the Ultimate Question of Life, the Universe and Everything. All we know about it is that the Answer is Forty-two, which is a little aggravating."
That's working on now. I'm trying to see if there is something like what im looking for to make things easer.
"It's just an online installer. It's not going to mug you.", JTH
"The shell is the key to unlock Linux's greatest advantages."
Here's how I handled saving settings the old fashioned PortableApps way (two years ago). The code may not work nowdays, but the comments could help you git-r-done. Scroll over to the right to read them.
Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!
That's almost exactly what the FF launcher was doing, from what I could tell.
btw, agdurrette, you will almost certainly want to use LogicLib...
"The question I would like to know, is the Ultimate Question of Life, the Universe and Everything. All we know about it is that the Answer is Forty-two, which is a little aggravating."
I think I read the original problem wrong. I thought it said the OP wanted a way to backup the files in APPDATA and keep using that location, not redirect the launcher to use data stored in a different location.
Mah bad.
Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!
Is LogicLib what you are using?
"It's just an online installer. It's not going to mug you.", JTH
"The shell is the key to unlock Linux's greatest advantages."
Yeah, I use LogicLib to make sure my code stays neat & clean. (As a matter of fact, I believe all portable apps are supposed to be using it now)
For the actual file backup/resume, I'm using the ReName function; for the registry backup/resume, I'm using Registry.nsh
I'm going to drop a new comment in here, with the relevant code portions attached.
"The question I would like to know, is the Ultimate Question of Life, the Universe and Everything. All we know about it is that the Answer is Forty-two, which is a little aggravating."
When I learned C (just a little) NSIS became this big mess of spaghetti.
Yeah, all portableapps should be using it now.
Insert original signature here with Greasemonkey Script.
Here's the relevant stuff from my TopOCR launcher. I actually copied some of this (the Registry backup/restore code) from the 7-Zip launcher, then modified it to work with TopOCR. You can probably do the same for Handbrake.
Anyway, here you go:
Includes:
TopOCR file handling
TopOCR Registry handling
Hint: Use the NISEdit search function to locate those section labels in TopOCR.nsi. The code will be much easier to read & understand when taken in context (and also with proper NSIS formatting).
HTH!
"The question I would like to know, is the Ultimate Question of Life, the Universe and Everything. All we know about it is that the Answer is Forty-two, which is a little aggravating."
Is there a reason that people don't use this anymore?
(Redirects APPDATA to $SETTINGSDIRECTORY)
It's used in quite a few launchers, if I recall correctly. Plus it works and avoids any of the hassles of moving files.
But there’s no sense crying over every mistake,
You just keep on trying till you run out of cake.
Cool :). Wil that also change APPDATA for other programs that use APPDATA?
"It's just an online installer. It's not going to mug you.", JTH
"The shell is the key to unlock Linux's greatest advantages."
yes. I wouldn't recommend doing it; backup & restore the Handbrake %APPDATA% folder instead. Look at the Firefox launcher to see how to do it... you could also modify the TopOCR launcher.
"The question I would like to know, is the Ultimate Question of Life, the Universe and Everything. All we know about it is that the Answer is Forty-two, which is a little aggravating."
@computerfreaker
Just so you know, Im not ignoring you, I am working on what your saying to do, I'm trying to find out how to move a folder with LogicLib, but while I am looking for that I'm also trying to get this working in hopes of less code.
"It's just an online installer. It's not going to mug you.", JTH
"The shell is the key to unlock Linux's greatest advantages."
yes, I know you're not ignoring me, you're just trying to do things in a better way.
For moving a folder with LogicLib, try something like this... it's off-the-cuff and totally untested, so it might not be perfect, but it should be close.
I don't recall how NSIS recognizes special folders; you might need to change $APPDATA to something else. Other than that, I believe that will cover you...
EDIT: nvm, just read gluxon's APPDATA redirection below. Hope you can get that working!
"The question I would like to know, is the Ultimate Question of Life, the Universe and Everything. All we know about it is that the Answer is Forty-two, which is a little aggravating."
Did not work :/
"It's just an online installer. It's not going to mug you.", JTH
"The shell is the key to unlock Linux's greatest advantages."
Wait, what's wrong with modifying the environment variables?
Do you know how to do that? That was agdurrette's original plan, but neither of us has been able to find a launcher that does it. Even the FF launcher, AFAICT, just backs up & restores the FF prefs folder in APPDATA.
Also, idk about him, but I've been unable to find any information on what I believe is the correct system call: SetEnvVariable(APPDATA)
"The question I would like to know, is the Ultimate Question of Life, the Universe and Everything. All we know about it is that the Answer is Forty-two, which is a little aggravating."
Actually, I do know how to do that
Here's the syntax used in most launchers (taken from Python Portable).
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("APPDATA", "$SETTINGSDIRECTORY").r0'
Just so you know, the modified environment variable only applies to the launcher and it's launched processes. Handy, eh?
The Call is also in Eclipse Portable, can't believe you guys never looked in there
Modifying the location for %APPDATA% would be very bad for your system since it's a Special Folder and all apps use it. Even temporary reldirection would be bad since you don't know what else is running on the user's machine. Chances are (according to Murphy's Law) another application will need to use the folder during the time you have it redirected.
http://en.wikipedia.org/wiki/Special_Folders
Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!
Ah!
So that's why even FF doesn't redirect %APPDATA%!
I reckon the backup/restore is your best (read: only) bet, agdurrette.
"The question I would like to know, is the Ultimate Question of Life, the Universe and Everything. All we know about it is that the Answer is Forty-two, which is a little aggravating."
Actually, the system plugin only affects the launcher and it's launched apps.
http://nsis.sourceforge.net/Setting_Environment_Variables_Examples
If I can just get it to work.
"It's just an online installer. It's not going to mug you.", JTH
"The shell is the key to unlock Linux's greatest advantages."
i have the code up if you want to look at it
"It's just an online installer. It's not going to mug you.", JTH
"The shell is the key to unlock Linux's greatest advantages."
OK, it's time for me to try and clarify everything.
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\AppData
. (This should not be used. There's actually a value in that key!Do not use this registry key
with the value "Use the SHGetFolderPath or SHGetKnownFolderPath function instead"!)Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
which is SHGetFolderPath, so either move data back and forth or try to patch it or ask them to.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
I don't have Handbrake installed on my system, so I can't test this, but it looks like you're not doing it quite the way MSDN would like...
Unfortunately, I don't know how to do this in NSIS.
"The question I would like to know, is the Ultimate Question of Life, the Universe and Everything. All we know about it is that the Answer is Forty-two, which is a little aggravating."
As I said just above, don't touch it. Anyhow, SetEnvironmentVariable is exactly what the System::Call is doing: but as I said above, you can't do it (especially with .NET applications; I suspect strongly without having tested it that USERPROFILE+APPDATA redirection won't work at all with .NET applications). Just move 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
App data redirect is not working. Will post on the HandBrake forum and see if there is any thing I can do.
"It's just an online installer. It's not going to mug you.", JTH
"The shell is the key to unlock Linux's greatest advantages."
I hate to say this, but you might want to just backup & restore the Appdata folder like most other launchers... that's probably the easiest way.
"The question I would like to know, is the Ultimate Question of Life, the Universe and Everything. All we know about it is that the Answer is Forty-two, which is a little aggravating."
I edited the original post which explains why I dont want to do that. But I am going to do that for now just so there will be something for people that want handbrake portable. It looks like I will have to rename the folders to be able to move it.
Also: did you get the reply to your email?
"It's just an online installer. It's not going to mug you.", JTH
"The shell is the key to unlock Linux's greatest advantages."
I understand why you don't want to do the backup/restore thing, but almost every other launcher does... you might want to reconsider. (Heck, even the Firefox launcher backs up & restores APPDATA...)
I got your e-mail reply, thanks!
Happy New Year!
"The question I would like to know, is the Ultimate Question of Life, the Universe and Everything. All we know about it is that the Answer is Forty-two, which is a little aggravating."