Skip to content
⌘ NSIS Forum Archive

How to Change $PLUGINSDIR (Nsis Unicode)

8 posts

Masternoob#

How to Change $PLUGINSDIR (Nsis Unicode)

Hello,

Is there a way to change the $PLUGINSDIR Variable?
I tried the chngvrbl.dll but it doesnt seem to work (not even the example that comes with the dll), i think this is because i use NSIS Unicode :/

so is there another way to change this Directory?
MSG#
Why do you think you want to change the $PLUGINSDIR variable?

If you're looking for a temporary directory, simply use $TEMP (in conjunction with GetTempFileName for added safety).
Masternoob#
the problem is that some of our customers are not allowed to execute somthing (like a dll) in the temp directory by their admins, they only have the permission for the temp directory of our application (which is a specific direcotry in %TEMP%), but when we use plugins in nsis they are executed from the $PLUGINSDIR not the $TEMPDIR directory so they can't update (we use nsis as an updater)

long story short:
The problem is that the Admins can't give the user the privileges for the Plugins folder because its doesn't have a static name
Yathosho#
couldn't you extract the plugin dlls to your preferred directory and call them with CallInstDLL?

(isn't it the purpose of admins to install the software in the first place?)
MSG#
Seems like a perfectly simple solution to me. What more do you want? If you want less code lines in your nsi script, just make a macro to wrap the pushes etc.
Masternoob#
it would be even easier if i could change $PLUGINSDIR 😁
but this solution works fine for me...i was just wondering if there was a way...

thank you for your help
Anders#
You should tell your admins to change their policy, the user should have full access to %temp%!

The next version of NSIS has UnsafeStrcpy, until then you are left with hacks.

Ugly system.dll hack:

!define EXEGVARSOFFSET 4386816 ; NSIS 2.46 zlib ANSI official, change this for different exehead
!ifdef NSIS_UNICODE
!define /math PDOFFSET 52 * ${NSIS_MAX_STRLEN}
!else
!define /math PDOFFSET 26 * ${NSIS_MAX_STRLEN}
!endif
!define /math PDPTR ${EXEGVARSOFFSET} + ${PDOFFSET}
StrCpy $0 "$Temp\MyNewPluginsDir"
CreateDirectory $0
File /oname=$0\system.dll "${NSISDIR}\Plugins\system.dll"
Push 'kernel32::lstrcpy(i ${PDPTR},tr0)'
CallInstDLL "$0\system.dll" Call
DetailPrint $PluginsDir
System::Call 'user32::MessageBox(i$hwndparent,t "Hello World",t "w00t",i0)'
Find the offset with:
StrCpy $0 "*PLUGINDIRHACK*"
System::Call kernel32::GetModuleHandle(i0)i.r1
;Save some time? StrCpy $1 4316816
loop:
System::Call 'kernel32::lstrcmp(ir1,tr0)i.r2'
StrCmp $2 0 done
IntOp $1 $1 + 1
goto loop
done:
DetailPrint $1