Old 10th August 2015, 14:12   #1
Mircea M
Junior Member
 
Join Date: Aug 2014
Posts: 44
$EXEDIR empty

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
Mircea M is offline   Reply With Quote
Old 10th August 2015, 14:59   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,263
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...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 10th August 2015, 19:39   #3
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Quote:
Originally Posted by Mircea M View Post
as far as I can tell, he never changes the value manually anywhere.
Did you also check all the .nsh files he might be including, either directly or indirectly?

Also, what version of MakeNSIS are you using to build that script? Do you use the Unicode or ANSI version?

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 11th August 2015, 05:49   #4
Mircea M
Junior Member
 
Join Date: Aug 2014
Posts: 44
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
Mircea M is offline   Reply With Quote
Old 11th August 2015, 06:09   #5
Mircea M
Junior Member
 
Join Date: Aug 2014
Posts: 44
Ok, found the spot. It is when I am setting a new Environment Variable. I have the following function:

code:
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:

code:
!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"



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.
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!
Mircea M is offline   Reply With Quote
Old 11th August 2015, 06:54   #6
Mircea M
Junior Member
 
Join Date: Aug 2014
Posts: 44
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
Mircea M is offline   Reply With Quote
Old 11th August 2015, 06:58   #7
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 886
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.

Quote:
Originally Posted by Mircea M View Post
code:
WriteRegExpandStr ${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

If it still empties $EXEDIR then there is something else going on.
JasonFriday13 is offline   Reply With Quote
Old 11th August 2015, 09:27   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,263
Quote:
Originally Posted by JasonFriday13 View Post
First, move the sendmessage command down after you modify the environment variable.
The broadcast applies to the registry key, moving it is not required.
Anders is offline   Reply With Quote
Old 11th August 2015, 22:52   #9
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 886
Cool, I just learned something new .

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump