You are here

Redirecting system folders, solution ?

13 posts / 0 new
Last post
Mark Sikkema
Offline
Last seen: 12 years 7 months ago
Developer
Joined: 2009-07-20 14:55
Redirecting system folders, solution ?

I know the following code for redirecting the 'userprofile'.

System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("USERPROFILE", "$SETTINGSDIRECTORY\UserProfile").r0'

But I wonder if there will be anyway of redirecting other system folders.

Like the following folders:

'Cookies', 'Local Settings' or even 'Temporary Internet Files' and 'History'

I have tried all sorts of combinations, but nothing seems to do the trick as 'USERPROFILE' does !

John T. Haller
John T. Haller's picture
Offline
Last seen: 6 hours 47 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Nope

And we don't use USERPROFILE because it has unintended consequences. It breaks the open/save dialogs that have the Desktop icon on the left. And any apps launched from the packaged app will carry that USERPROFILE, so you can wind up with lots of other stuff redirected.

We only use it in a couple small apps that have no ability to open/save/browse or call other apps. Like Sudoku Portable, for example.

Sometimes, the impossible can become possible, if you're awesome!

Mark Sikkema
Offline
Last seen: 12 years 7 months ago
Developer
Joined: 2009-07-20 14:55
Thats accactly why I am not wanting to use USERPROFILE it self

But for the winamp browser to be portable, without leaving traces, I need to some how to redirect the cookies, temporary internet files, and probably history.

About Winamp launching other apps, all I remember for now it does launch is internet explorer!

Would you know a different way of portabilizing this browser in Winamp, or do you think it isn't a problem to leave these traces ?

Formerly Gringoloco
Windows XP Pro sp3 x32

OliverK
OliverK's picture
Offline
Last seen: 2 years 10 months ago
Developer
Joined: 2007-03-27 15:21
yes. Use the same sort of

yes. Use the same sort of code to redirect those individual folders.

Too many lonely hearts in the real world
Too many bridges you can burn
Too many tables you can't turn
Don't wanna live my life in the real world

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

As far as I know, no-one here has worked out a decent way of clearing cache - that's part of the reason that RSSOwl hasn't gone official, as it uses Internet Explorer as its internal browser, but still leaves everything in its cache behind.

If it requires and uses Internet Explorer, we're stymied.

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

Mark Sikkema
Offline
Last seen: 12 years 7 months ago
Developer
Joined: 2009-07-20 14:55
Would this be allowed ???

I have been playing around with the problem of the above code, and found a kind of solution !
The following code moves(backs up) the Desktop value which consists a relative path '%USERPROFILE%\Desktop', then writes the same path but absolute, in my case 'C:\Documents and Settings\Gringoloco\Desktop'. Then changes the environment variable, followed by an immediate restore of the original Desktop value! When my script executed Winamp after this code, Winamp could find the desktop without a problem, but still had the (Winamp) browser saving it's cookies and temporary internet files to the Data\UserProfile folder.

Probably (hopefully) this could work for all system folders affected by %USERPROFILE% !

StrCpy $1 "$DESKTOP"
${registry::MoveValue} "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" "Desktop" "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" "Desktop-BackupByPortableApps" $R0
${registry::Write} "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" "Desktop" "$1" "REG_EXPAND_SZ" $R0
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("USERPROFILE", "$SETTINGSDIRECTORY\UserProfile").r0' ; set new user profile folder
Sleep 1000 
${registry::DeleteValue} "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" "Desktop" $R0
${registry::MoveValue} "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" "Desktop-BackupByPortableApps" "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" "Desktop" $R0

It does the trick for windows XP, but I would need a little help to make this work for Vista and Windows 7 !!!

Formerly Gringoloco
Windows XP Pro sp3 x32

wraithdu
Offline
Last seen: 10 years 11 months ago
Developer
Joined: 2007-06-27 20:22
I have a feeling this is

I have a feeling this is working by sheer luck, and is certainly not a method to be relied upon. Apps can get profile directories in at least 3 different ways - query the environment, read the registry, explicit API calls. Ideally apps should only use one method. Sounds like Winamp is using a combination (bad programming IMO).

That could change at any time, of course, and break your portability. Also you cannot guarantee other apps get profile directories in the same way.

Mark Sikkema
Offline
Last seen: 12 years 7 months ago
Developer
Joined: 2009-07-20 14:55
I have to do more testing, I know !

But it seems to me that this is a way of getting the Desktop folder to not be included in the redirection of the USERPROFILE for solely Winamp.exe (and any other app what will be executed from within Winamp), but this way the rest of windows doesn't seem affected !

Give it a try!

Formerly Gringoloco
Windows XP Pro sp3 x32

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 8 years 10 months ago
Joined: 2007-04-15 21:08
Don't touch it

That's a high explosive device. Don't touch it or you may get blown up.

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

Mark Sikkema
Offline
Last seen: 12 years 7 months ago
Developer
Joined: 2009-07-20 14:55
Could you specify that last comment !!!

Ok, done some more testing, and 'strangely' enough after a reboot I can't get it to behave the way it did for me before. But, maybe there is a chance this could actually lead to something. Don't you think it got potential ?

There must have been a reason, after all the tweaking I tried before, it did actually work perfectly..... till I did my reboot ! Winamp still finds the real Desktop, but started giving the error message again Sad
Yes I am using a frozen harddisk anyway, so I'm not scared to destroy my registry. But getting blown up ???

Formerly Gringoloco
Windows XP Pro sp3 x32

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 8 years 10 months ago
Joined: 2007-04-15 21:08
Don't touch it

I mean what I say, don't touch it. You could really screw a system up that way. And I doubt that the user would like that.

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

Mark Sikkema
Offline
Last seen: 12 years 7 months ago
Developer
Joined: 2009-07-20 14:55
Ok, probably this isn't the direction I want to go !

If you say this won't lead to anything, I won't touch it anymore.

Will find another solution......

Maybe just a shortcut to the desktop, like this Data\UserProfile\Desktop\Desktop.lnk

This will also get rid of the error message, and keeps a link to the desktop. Just have to get the launcher to update the path in this link.

Changing userprofile, without the error message, do you think that will be good enough for an 'official release' ? (one day)

Formerly Gringoloco
Windows XP Pro sp3 x32

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

We don't touch USERPROFILE on anything like that. Something like Sudoku, or SuperTux, or some other game which does nothing like file or directory picking or spawning processes, would be as far as we'd go.

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