$EXEDIR resolved to UNC path in NSIS

While testing a installer created using NSIS I came across a interesting problem the other day. While the installer worked perfectly on Windows XP it failed on Windows Vista and Windows 7. The reason was that the $EXEDIR variable was pointing to a mapped drive and on Windows Vista and Windows 7 this was automatically resolved to an UNC path. This was not expected behaviour and the resulting install was incorrect.

I tracked the cause of the problem down to the install attribute “RequestExecutionLevel”. In my install it was set to Admin. It seems like this loads the admin user profile and obviously the drive was not mapped in that user profile. The workaround for this problem is to set the attribute to Highest instead. Alternatively User could have been used but since the installer required elevation I used Highest.