Skip to content
⌘ NSIS Forum Archive

ProgramData Redirect

6 posts

PoRtAbLe_StEaLtH#

ProgramData Redirect

Any gurus here can help?

im trying to redirect ProgramData vis SetEnvironmentVariables, but no luck.
Here's what ive tried:

Scenario 1:
StrCpy $R0 "$EXEDIR\Data"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PROGRAMDATA", "$R0").r0' 
Scenario 2:
!define MYVAR `$INSTDIR`
ReadEnvStr $R0 "PROGRAMDATA"
StrCpy $R0 "$R0;${MYVAR}"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PROGRAMDATA", "$R0").r2'
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
ReadEnvStr $0 "PROGRAMDATA"
messagebox mb_ok '$0' 


neither worked..
However .. just as a test.. i hardcoded in:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\ProgramData

and it worked, the app launched.


is there a way i can do that only affects the app?

Thanks in advance
PoRtAbLe_StEaLtH#
Originally Posted by Anders View Post
StrCpy $R0 "$R0;${MYVAR}" is not going to work, %programdata% is not %path%
is what im trying to do even possible, where it only affects the app, and child processes?
Anders#
Sure but you cannot set it to more than one path.

ReadEnvStr $0 "PROGRAMDATA" 
System::Call 'Kernel32::SetEnvironmentVariable(t "PROGRAMDATA", t "c:\foo")'
ExecWait '"$instdir\bar.exe"'
System::Call 'Kernel32::SetEnvironmentVariable(t "PROGRAMDATA", tr0)' #restore it
PoRtAbLe_StEaLtH#
Originally Posted by Anders View Post
Sure but you cannot set it to more than one path.

ReadEnvStr $0 "PROGRAMDATA" 
System::Call 'Kernel32::SetEnvironmentVariable(t "PROGRAMDATA", t "c:\foo")'
ExecWait '"$instdir\bar.exe"'
System::Call 'Kernel32::SetEnvironmentVariable(t "PROGRAMDATA", tr0)' #restore it
Thank you very much, especially for not beating around the bush.

It works just as expected, but after all that.. the app. doesn't respond.
I suspect it's querying ProgramData from a different location.
Anders#
Originally Posted by PoRtAbLe_StEaLtH View Post
It works just as expected, but after all that.. the app. doesn't respond.
I suspect it's querying ProgramData from a different location.
It is probably using one of the SHGet[Special/Known]Folder[Location] functions, that is the documented way to get special paths...