1
votes

I am trying to learn NSIS to create an installer and an uninstaller for a project and I am trying to follow the examples in the tutorial section. I tried the following script:-

# define the name of the installer
outfile "installer.exe"

# define the directory to install to, the desktop in this case as specified  
# by the predefined $DESKTOP variable
installDir $DESKTOP\Harshit\NSIS\Scripts

# default section
section

# define the output path for this file
setOutPath $DESKTOP\Harshit\NSIS\Files

# define what to install and place it in the output path
File test1.txt

# define uninstaller name
writeUninstaller $DESKTOP\Harshit\NSIS\Scripts\uninstaller.exe

sectionEnd

# create a section to define what the uninstaller does.
# the section will always be named "Uninstall"
section "Uninstall"

# Always delete uninstaller first
delete $DESKTOP\Harshit\NSIS\Scripts\uninstaller.exe

# now delete installed file
delete $DESKTOP\Harshit\NSIS\Scripts\Files\test1.txt

sectionEnd

However, I am getting an error that says:

invalid script: never had OutFile command.

I can see the outfile command at the top but I can't figure out why it is not working. Any advice please?

1
This happens when your .nsi file has CR line endings. Try mac2dos.exe or mac2unix.exe then unix2dos.exe your .nsi then recompile. - HernĂ¡n

1 Answers

4
votes

Could it be as simple as you working on one .nsi file and actually passing a different .nsi file to the compiler?

You could add !error "Hello World" or something simple like that to the top of your script to find out...

Edit:

If it cannot open the output file for writing the error message should be "Can't open output file" and not related to OutFile.

Unless you are passing in the script with stdin it should pick the .nsi filename as the base name even if you don't use OutFile at all.

Could you please show use the exact parameters you pass to makensis.exe and a copy of your real script?