Archive: Needy Newby...


Needy Newby...
I have NEVER used a scripting language before.

I need to produce an installation package for an executable that will also include transferring text files and installing a font. I'd like to show a licensing agreement. I'd also like to find out if there is some way to add very basic copy protection using the registry. (I'll live without the last if it is too complicated for me to implement.)

I have the NSIS software installed. I was hoping for an interface that would let me check some options, type in names under "Executable", "Text Files", and "Fonts" headings, and, if need be, check a box under "use registry for copyright protection", then push the compile button. I know that's too easy. I've looked through the on-line working files, and find nothing that seems directly relevant. Honestly, they don't even make a lot of sense right now.

When I start something new like this, I usually begin with a file that works and that has a manual that describes each line on a line-by-line basis. That starter file tends to do most of what I need, then I try to modify it to get it to do precisely what I want. When it doesn't, I post it with a question at a forum like this. Once the basic file works, I shouldn't need to be such a pain in the rear in the future, because I'll just change the names of the executables and text files or delete the add font section if I don't need to check for or add a font. (For example, I need to check for the "Courier" font and add it if it's not already there, or at least put up a warning that the user needs to add it or the software won't work if I can't legally distribute Courier, which I probably shouldn't attempt. I know that Courier should be present in Windows, but who knows, perhaps there are Courier font phobics out there who have deleted it...)

I know there probably isn't that check box executable creation option out there. Is there at least a working source file and some instructions on how to make it compile, or whatever is necessary to at least test the installation? The last time I tried this VB came with its own installation wizard that produced the installshield files... So much for the "good old days"...

Thanks for any assistance in advance.


My opinion is start with the basics. :-)
I can't think of a better way than to start compile and study the included examples.


(USING CAPS JUST TO DIFFERENTIATE FROM SUBSEQUENT TEXT.)

I'VE TAKEN A QUICK LOOK AT THE EXAMPLE TWO. I WOULD MODIFY IT AS FOLLOWS TO ADD COPYING OF "TEXT1.TXT" AND "TEXT2.TXT" TO THE INSTALLATION DIRECTORY. I SAW NO EXAMPLE THAT WOULD SHOW ME HOW TO CHECK FOR A FONT AND INSTALL IF ITS NOT THERE, OR HOW TO ADD A LICENSING AGREEMENT SCREEN. THANKS FOR ANY INPUT:


; example2.nsi
;
; This script is based on example1.nsi, but it remember the directory,
; has uninstall support and (optionally) installs start menu shortcuts.
;
; It will install example2.nsi into a directory that the user selects,

;--------------------------------

; The name of the installer
Name "Example2"

; The file to write
OutFile "example2.exe"
OutFile "Text2.txt"
OutFile "Text1.txt"

; The default installation directory
InstallDir $PROGRAMFILES\Example2

; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\NSIS_Example2" "Install_Dir"

;--------------------------------

; Pages

Page components
Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

; The stuff to install
Section "Example2 (required)"

SectionIn RO

; Set output path to the installation directory.
SetOutPath $INSTDIR

; Put file there
File "example2.nsi"
file "text1.txt"
file "text2.txt"

; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\NSIS_Example2 "Install_Dir" "$INSTDIR"

; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "DisplayName" "NSIS Example2"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "NoRepair" 1
WriteUninstaller "uninstall.exe"

SectionEnd

; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"

CreateDirectory "$SMPROGRAMS\Example2"
CreateShortCut "$SMPROGRAMS\Example2\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\Example2\Example2 (MakeNSISW).lnk" "$INSTDIR\example2.nsi" "" "$INSTDIR\example2.nsi" 0

SectionEnd

;--------------------------------

; Uninstaller

Section "Uninstall"

; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2"
DeleteRegKey HKLM SOFTWARE\NSIS_Example2

; Remove files and uninstaller
Delete $INSTDIR\example2.nsi
Delete $INSTDIR\uninstall.exe

; Remove shortcuts, if any
Delete "$SMPROGRAMS\Example2\*.*"

; Remove directories used
RMDir "$SMPROGRAMS\Example2"
RMDir "$INSTDIR"

SectionEnd


I SAW NO EXAMPLE THAT WOULD SHOW ME HOW TO CHECK FOR A FONT AND INSTALL IF ITS NOT THERE...
http://nsis.sourceforge.net/Register_Fonts
http://nsis.sourceforge.net/FontName_plug-in

...OR HOW TO ADD A LICENSING AGREEMENT SCREEN.
For a beginning study the example basic.nsi. You'll find it at ${NSISDIR}\Examples\Modern UI.
( ${NSISDIR} is the location of NSIS installation on your machine )

HM NIS Edit is an AWESOME editor for NSIS. I tried it and was awed with it's ability to generate an easy script to start with. From there I just kept editing the script making it better.

It uses a Wizard to generate a script based on the type of install and files you put into it.

It's pretty cool. I started using it and haven't looked back.
http://hmne.sourceforge.net/

(If anyone gets mad b/c i'm mentioning it to alot of people then let me know. I really like it but i won't tell ppl about it if it's a problem)
SAM!


The attached two files are named Example2 and license.txt, so don't put the first in your NSIS example's directory, or you'll lose the original.

I've tried to incorporate the show license script from the home page, but I don't seem to have broken it up appropriately to get it to run while adding it to Example2. There must be some order in which the bits and pieces have to go that I don't yet have correct. As I indicated, I've tried to integrate it into Example2 from the examples directory. Can anyone advise how to get this file's contents into the correct order? It does compile, but it won't flash the license text (which is also attached and is merely the example2 file text) with an "I agree" button on the screen. Can anyone help get me get this file's contents straightened out, so I can move on to trying to add some basic "Enter license number" screen and a mathematical test to see if the license number meets the licensing algorithm's requirements, and be done with my not so fancy installation program?

Thank you.


I just took sag47's advice. If this tool does what my one time through the menu suggests it can do, I should be all set until the time comes to figure out how to get a user input and perform some mathematical tests to determine if its conforms to a licensing test algorithm.


DJ2006, you could use [code] to differentiate code from text. There's no need for caps.


Ah, but that requires internet sophistication, and a specific form of knowledge, which I lack...


Then start reading ;) The bottom of the page has a link to vB code guide which tells you all you need to know.