Archive: ProgramData Redirect


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

StrCpy $R0 "$R0;${MYVAR}" is not going to work, %programdata% is not %path%


Originally posted by Anders
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?

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

Originally posted by 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
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.

Originally posted by PoRtAbLe_StEaLtH
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...