Hi,
I wanted to ask what I could possibly do wrong so that $EXEDIR returns an empty string. I am working on a relatively old piece of code that I took over from a colleague that left the company but as far as I can tell, he never changes the value manually anywhere.
Thanks,
Mircea
$EXEDIR empty
9 posts
A broken plugin could corrupt it.
Try a MessageBox at the start of .onInit and go from there to track down the source of the problem...
Try a MessageBox at the start of .onInit and go from there to track down the source of the problem...
Did you also check all the .nsh files he might be including, either directly or indirectly?Originally Posted by Mircea M View Postas far as I can tell, he never changes the value manually anywhere.
Also, what version of MakeNSIS are you using to build that script? Do you use the Unicode or ANSI version?
Hi,
started the MessageBox approach but it will take some time as there's a lot of code and different installation paths. Hopefully I will find something soon.
I am using the ANSI version and I also checked all the .nsh files - all seems ok in there too.
Thanks for the tips!
Mircea
started the MessageBox approach but it will take some time as there's a lot of code and different installation paths. Hopefully I will find something soon.
I am using the ANSI version and I also checked all the .nsh files - all seems ok in there too.
Thanks for the tips!
Mircea
Ok, found the spot. It is when I am setting a new Environment Variable. I have the following function:
Any ideas why?
I could save the value of $EXEDIR to a temporary variable and re-assign it at the end of the function but I would like to know why this happens, if I am doing something wrong.
Thanks!
WriteRegExpandStr ${IDI_HOME_ROOT_KEY} "${IDI_HOME_KEY}" "${IDI_HOME_VAR}" "${IDI_HOME_VAL}"
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
StrCpy $R0 "${IDI_HOME_VAL}"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i(${IDI_HOME_VAR}, R0).r0'
The variables (constants) that I use are:After I do this, my Env. Var. is set correctly but $EXEDIR is empty. The actual line that causes the problem is the System::Call one.!define IDI_HOME_ROOT_KEY "HKLM"
!define IDI_HOME_KEY "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
!define IDI_HOME_VAR "IDI_HOME"
!define IDI_HOME_VAL "$INSTDIR"
Any ideas why?
I could save the value of $EXEDIR to a temporary variable and re-assign it at the end of the function but I would like to know why this happens, if I am doing something wrong.
Thanks!
Update
Seems that if I remove the System::Call statements my environment variable is still available during the installation for the installer and it's sub-processes.
I did that and now everything works.
It would still be interesting to know why that System::Call "deleted" $EXEDIR 🙂
Seems that if I remove the System::Call statements my environment variable is still available during the installation for the installer and it's sub-processes.
I did that and now everything works.
It would still be interesting to know why that System::Call "deleted" $EXEDIR 🙂
First, move the sendmessage command down after you modify the environment variable. Also try changing the system::call function so it's char type agnostic.
If it still empties $EXEDIR then there is something else going on.Originally Posted by Mircea M View PostWriteRegExpandStr ${IDI_HOME_ROOT_KEY} "${IDI_HOME_KEY}" "${IDI_HOME_VAR}" "${IDI_HOME_VAL}"
StrCpy $R0 "${IDI_HOME_VAL}"
System::Call 'Kernel32::SetEnvironmentVariable(t "${IDI_HOME_VAR}", t R0)'
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
The broadcast applies to the registry key, moving it is not required.Originally Posted by JasonFriday13 View PostFirst, move the sendmessage command down after you modify the environment variable.
Cool, I just learned something new 🙂.