Skip to content
⌘ NSIS Forum Archive

Changing directory to call an executable?

8 posts

kraucer#

Changing directory to call an executable?

I need to change the path at runtime. It would be the same command as the "change directory" cd. How can I do this in NSIS?

!define OCS_INSTALL_FILE "C:\ocs\install\ocs_setup.exe"
!define OCS_INSTALL_OPTIONS "/S /NP /NO_SYSTRAY /NOSPLASH /NO_SERVICE"
!define OCS_SERVER "http://myserver.com/ocsinventory"

ExecWait "'${OCS_INSTALL_FILE} ${OCS_INSTALL_OPTIONS} /SERVER=${OCS_SERVER}'"

The command "ExecWait" not working if called with the provided path. It only works if I call the direct path but for that I need to change the path.

ExecWait "ocs_setup.exe" is fine.
kraucer#
No, the problem is not just this. The problem is that "ocs_setup.exe" can only be executed if he is in the same way my NSIS installer.

An example: if I save my instalador_nsis.exe and ocs_setup.exe in the directory.
c:\ocs\ocs_setup.exe
c:\ocs\my_install.exe

The way it works above. If the way down, does not work:

c:\ocs\install\ocs_setup.exe
c:\ocs\my_install.exe
kraucer#
Resolved, added 'at the beginning and end of the path variable in ExecWait. Thank you for your attention.
Afrow UK#
You should never use relative paths. If you do need a path relative to the running installer, use $EXEDIR\.... And yes, you need quotes (the manual clearly states this). They should be double quotes too, so '"[path]"'.

Stu
Afrow UK#
Originally Posted by MSG View Post
I don't think you need double quotes for any NSIS command. ' or ` work fine too.
We're talking about the executable path for ExecWait (you need double quotes around it).

Stu
MSG#
Oh I see, the manual does show
ExecWait '"$INSTDIR\someprogram.exe"'
as the example. Guess it's the same as what Anders and I discussed about putting the ARP uninstall path between quotes. I'll add it to my checklist. :P