Skip to content
⌘ NSIS Forum Archive

Variable Source Path

5 posts

langdon#

Variable Source Path

I'm trying to get my NSIS script able to be compiled on two different machines with different directory structures. I thought I could simply:

Var Path
Function .OnInit
    StrCpy $Path "c:\test.txt"
FunctionEnd
Section
    File "${Path}"
SectionEnd 
...but obviously variables are for run-time use only. What I need is some sort of compile-time constant. I was hoping to be able to create an NSH file on my machine that sets the source path to "c:\source_files", and the build machine could have the same NSH file, but point it do d:\project\latest". Or maybe even something simpler?

Any ideas?

TIA!
Anders#
mypath.nsh:
!define thepath "c:\foo\bar"

install.nsi:
!include "mypath.nsh"
...
File "${thepath}\somefile.exe"
langdon#
Thanks Anders!

@MSG, putting the !define at the top of the script won't allow that same script to run on multiple environments.
demiller9#
You can use relative paths in the define, or directly in the FILE commands. I do this to work at home and at the office, where my NSIS folders are on different drives
!define Addons "\NSIS Installers\Addons"
!AddPluginDir "${Addons}\Plugins"
!AddIncludeDir "${Addons}\Include"
...
!define SRCDIR ".\Ipls.3177"
File "${SRCDIR}\ArchHelpUtil*.ocx"