99999999
18th June 2007 23:16 UTC
Using replaceable strings in the /D commandline option
Hi I am working on changing our code, so that our package manager, can download packages, and they can be installed to the base path, chosen by a user.
The problem is that the current installer packages we download, (which are NSIS installers,) set their $INSTALLDIR to "$PROGRAMFILES\${INSTALLDIRECTORYNAME}" ${INSTALLDIRECTORYNAME} is determined at build time for the installer, and is different for each package.
When we use the /D command the issue I have is that our package manager, doesn't know what "${INSTALLDIRECTORYNAME}" is. And as a result we can't use the /D commandline this way.
What I am wondering is if there is means of using some replacement in the command line. for instance /D=c:\mynewdirectory\${INSTALLDIRECTORYNAME}
And I was wondering if this, or something like it, was possible.
Afrow UK
18th June 2007 23:26 UTC
Why not use two defines, one of which (INSTALLDIRECTORYNAME) is hard coded into the script, and another which is defined on the command line (say INSTALLROOTDIRECTORY).
Assuming you don't have this already, you might have:
!ifndef INSTALLROOTDIRECTORY
!define INSTALLROOTDIRECTORY "$PROGRAMFILES"
!endif
!ifndef INSTALLDIRECTORYNAME
!define INSTALLDIRECTORYNAME "MyApp"
!endif
InstallDir "${INSTALLROOTDIRECTORY}\${INSTALLDIRECTORYNAME}"
Stu
99999999
18th June 2007 23:42 UTC
Ahh sorry, I didn't explain. We want to be able to do this, for what amounts to some 1300 packages, which we don't want to have to rebuild.
And we want to let the user choose, during the package manager's installation, where packages should be installed to.
Afrow UK
19th June 2007 09:57 UTC
I'm totally lost sorry lol
/D is a makensis switch, or have you added support for it in your installer?
Stu
DrDan
19th June 2007 16:22 UTC
/D = instdir
Look in section 4.12 of the documenation, it explains this well. The quote is:
Since the directory page can not be shown on silent installers, the user has an option to specify the installation directory on the command line (this also works on non-silent installers/uninstallers). To do that, the user uses the /D switch as in the following example:
foo.exe /S /D=C:\Program Files\Foo
Afrow UK
19th June 2007 17:14 UTC
So basically you want to append a directory name onto the end of $INSTDIR in .onInit if it isn't already appended...
Stu