PoRtAbLe_StEaLtH
4th December 2012 14:35 UTC
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
Anders
4th December 2012 15:53 UTC
StrCpy $R0 "$R0;${MYVAR}" is not going to work, %programdata% is not %path%
PoRtAbLe_StEaLtH
5th December 2012 06:24 UTC
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?
Anders
5th December 2012 10:56 UTC
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
5th December 2012 14:27 UTC
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.
Anders
5th December 2012 20:24 UTC
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...