Simple tutorials: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
{{PageAuthor|eldri005}}
==Simple hello world - popup box==
==Simple hello world - popup box==
This hello world script will create a popup box with the words "hello world" in it and an "OK" button, when the installer is run
This hello world script will create a popup box with the words "hello world" in it and an "OK" button, when the installer is run

Revision as of 23:36, 22 May 2006

Author: eldri005 (talk, contrib)


Simple hello world - popup box

This hello world script will create a popup box with the words "hello world" in it and an "OK" button, when the installer is run

# set the name of the installer
outfile "hello world.exe"
 
# create a default section.  Every NSIS script has at least one section
section
 
# create a popup box, with an OK button and the text "Hello world!"
messageBox MB_OK "Hello world!"
 
sectionEnd

Simple hello world - writing text to a file

This hello world script will write "hello world" to a text file when the installer is run

# declare name of finstaller file
outfile "hello world.exe"
 
# open section
section
 
/* open an output file called "helloworld.txt", 
which must exist before script is compiled, 
on the desktop in write mode */
fileOpen $0 "$DESKTOP\helloworld.txt" w
 
# write the string "hello world!" to the output file
fileWrite $0 "hello world!"
 
# close the file
fileClose $0
 
# end the section
sectionEnd

Simply install a file

This installer script will copy the file "test.txt" to the installation directory

# define the name of the installer
outfile "simple installer.exe"
 
# define the directory to install to, the desktop in this case as specified  
# by the predefined $DESKTOP variable
installDir $DESKTOP
 
# default section
section
 
# define the output path for this file
setOutPath $INSTDIR
 
# define what to install and place it in the output path
file test.txt
 
sectionEnd