Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 427 lines (332 sloc) 11.293 kb
; $Id: nfs.nsi,v 1.19 2007/05/08 14:12:48 dancy Exp $
;; Disable compression when developing (severely speeds up the debug
;; cycle)
;;SetCompress off
SetCompressor /SOLID lzma
!include WinMessages.nsh
!include servicelib.nsh
; Author: Lilla ( 2003-06-13
; function IsUserAdmin uses plugin \NSIS\PlusgIns\UserInfo.dll
; This function is based upon code in \NSIS\Contrib\UserInfo\UserInfo.nsi
; This function was tested under NSIS 2 beta 4 (latest CVS as of this writing).
; Usage:
; Call IsUserAdmin
; Pop $R0 ; at this point $R0 is "true" or "false"
Function IsUserAdmin
Push $R0
Push $R1
Push $R2
IfErrors Win9x
Pop $R1
Pop $R2
StrCmp $R2 "Admin" 0 Continue
; Observation: I get here when running Win98SE. (Lilla)
; The functions UserInfo.dll looks for are there on Win98 too,
; but just don't work. So UserInfo.dll, knowing that admin isn't required
; on Win98, returns admin anyway. (per kichik)
StrCpy $R0 "true"
Goto Done
; You should still check for an empty string because the functions
; UserInfo.dll looks for may not be present on Windows 95. (per kichik)
StrCmp $R2 "" Win9x
StrCpy $R0 "false"
Goto Done
; we don't work on win9x...
StrCpy $R0 "false"
Pop $R2
Pop $R1
Exch $R0
!macro StopAndDeleteService UN
Function ${UN}StopAndDeleteService
Push running
Push nfs
Push ""
Call ${UN}Service
Pop $0 ;response
StrCmp $0 "true" 0 ServiceStopped
; Not using servicelib.nsh to stop the service because it
; does not wait until the service is fully stopped.
;Push "stop"
;Push "nfs"
;Push ""
;Call Service
;Pop $0 ;response
DetailPrint "Stopping NFS service..."
ExecWait '"$WINDIR\system32\net.exe" stop nfs'
;; now delete
DetailPrint "Removing NFS service..."
Push delete
Push nfs
Push ""
Call ${UN}Service
Pop $0 ;response
;; Allow time for console's to exit, etc.
Sleep 5000
!insertmacro StopAndDeleteService ""
!insertmacro StopAndDeleteService un.
;; Not used anymore, but leaving the code here for
;; educational purposes.
!macro StopConsole UN
Function ${UN}StopConsole
;; This probably won't work for consoles running in other
;; windows stations/desktops.
FindWindow $0 "" "Allegro NFS Console"
IsWindow $0 0 NoMoreConsoles
DetailPrint "Terminating Allegro NFS Console..."
SendMessage $0 ${WM_CLOSE} 1 0
Sleep 3000 ;; Allow time for it to die
Goto FindWindowLoop
!insertmacro StopConsole ""
!insertmacro StopConsole un.
!define REGKEY "Software\Franz Inc.\Allegro NFS ${VERSION}"
!define VERBOSE_PROD "Allegro NFS ${VERSION} Server for Windows"
!define SHORT_PROD "Allegro NFS ${VERSION}"
; for DEP workaround
!define APPCOMPATLAYERS "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
; The installer program that will be created
OutFile "dists\setup-nfs-${VERSION2}.exe"
; The default installation directory
InstallDir "c:\AllegroNFS"
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "${REGKEY}" "Install_Dir"
!ifdef NFSDEMO
LicenseData license-demo.txt
LicenseData license-paid.txt
; IsWin9x
; Base on GetWindowsVersion from
; Based on Yazno's function,
; Updated by Joost Verburg
; Returns on top of stack
; Windows Version (95, 98, ME, NT x.x, 2000, XP, 2003)
; or
; '' (Unknown Windows Version)
; Usage:
; Call IsWin9x
; Pop $R0
; ; at this point $R0 is "true" or "false"
Function IsWin9x
Push $R0
Push $R1
ReadRegStr $R0 HKLM \
"SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
IfErrors 0 lbl_winnt
; we are not NT
StrCpy $R0 "true"
Goto lbl_done
StrCpy $R0 "false"
Pop $R1
Exch $R0
Function .onInit
Call IsWin9x
Pop $R0 ; at this point $R0 is "true" or "false"
StrCmp $R0 "true" 0 IsWinNT
MessageBox MB_OK \
'Allegro NFS Server does not work on Windows 9x.'
Call IsUserAdmin
Pop $R0 ; at this point $R0 is "true" or "false"
StrCmp $R0 "false" 0 IsAdmin
MessageBox MB_OK \
'You must be a member of the Administrators group to install.'
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "Global\AllegroNFSInstallMutex") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
; Pages
Page license
Page components
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
; The stuff to install
Section "${VERBOSE_PROD}"
SectionIn RO
; Set output path to the installation directory.
SetOutPath "$INSTDIR"
; Perform all operations within the 'All Users' context.
SetShellVarContext all
;;Call StopConsole
Call StopAndDeleteService
;;;;;;; now install the files...
File /r "nfs\*"
!ifdef NFSDEMO
File /oname=license.txt "license-demo.txt"
File /oname=license.txt "license-paid.txt"
File "nfs.cfg.default"
;; nfs.cfg
; If nfs.cfg is already there, don't overwrite it.
IfFileExists "$INSTDIR\nfs.cfg" HasExistingConfig
;; Check for configuration files from previous versions, and copy
;; it into the newly named installation directory.
IfFileExists "C:\Program Files (x86)\Allegro NFS\nfs.cfg" 0 CheckFor32Bit
StrCpy $0 "C:\Program Files (x86)\Allegro NFS\nfs.cfg"
StrCpy $1 "$INSTDIR\nfs.cfg"
StrCpy $2 1 ; 0 to overwrite file if it already exists
System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l'
Pop $0 ; pops a bool. if overwrite is off and there is a file then error will be 1
StrCmp $0 "true" 0 HasExistingConfig
MessageBox MB_OK 'Error creating nfs.cfg [1]'
IfFileExists "C:\Program Files\Allegro NFS\nfs.cfg" 0 DefaultConfig
StrCpy $0 "C:\Program Files\Allegro NFS\nfs.cfg"
StrCpy $1 "$INSTDIR\nfs.cfg"
StrCpy $2 1 ; 0 to overwrite file if it already exists
System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l'
Pop $0 ; pops a bool. if overwrite is off and there is a file then error will be 1
StrCmp $0 "true" 0 HasExistingConfig
MessageBox MB_OK 'Error creating nfs.cfg [2]'
Goto HasExistingConfig
File /oname=nfs.cfg nfs.cfg.default
; Write the installation path into the registry
WriteRegStr HKLM "${REGKEY}" "Install_Dir" "$INSTDIR"
; See if we need to work around DEP
Push $1
System::Call "apphelp::ShimFlushCache(i 0, i 0, i 0, i 0) i .r1"
; $1 will be "error" if there is no apphelp on this system.
; $1 will be 1 if the call succeeded, which means we need to
; work around DEP.
IntCmp $1 1 0 noDEP noDEP
DetailPrint "Installing DEP workarounds"
; Turn off DEP for Allegro NFS programs
; Add registry entries
WriteRegStr HKLM "${APPCOMPATLAYERS}" "$INSTDIR\nfs.exe" "DisableNXShowUI"
WriteRegStr HKLM "${APPCOMPATLAYERS}" "$INSTDIR\configure\configure.exe" "DisableNXShowUI"
System::Call "apphelp::ShimFlushCache(i 0, i 0, i 0, i 0)"
Pop $1
!define UNINSTMAIN "Software\Microsoft\Windows\CurrentVersion\Uninstall"
; Write the uninstall keys for Windows
WriteRegStr HKLM "${UNINSTKEY}" "DisplayName" "${VERBOSE_PROD}"
WriteRegStr HKLM "${UNINSTKEY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "${UNINSTKEY}" "NoModify" 1
WriteRegDWORD HKLM "${UNINSTKEY}" "NoRepair" 1
WriteUninstaller "uninstall.exe"
ExecWait '"$INSTDIR\nfs.exe" /install /quiet'
; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"
SetShellVarContext current
; Delete any old shortcuts that were installed in the current user area
RMDir /r "${SMDIR}"
SetShellVarContext all
; Start with a clean state
RMDir /r "${SMDIR}"
CreateDirectory "${SMDIR}"
CreateShortCut "${SMDIR}\Uninstall.lnk" "$INSTDIR\uninstall.exe"
;; These don't work on Vista. They're not really necessary anyway.
;;CreateShortCut "${SMDIR}\Start NFS Service.lnk" "%windir%\system32\net.exe" "start nfs"
;;CreateShortCut "${SMDIR}\Stop NFS Service.lnk" "%windir%\system32\net.exe" "stop nfs"
CreateShortCut "${SMDIR}\Configure ${VERBOSE_PROD}.lnk" \
CreateShortCut "${SMDIR}\${SHORT_PROD} Console.lnk" \
"$INSTDIR\nfs.exe" "/console"
CreateShortCut "${SMDIR}\Check for program update.lnk" \
Section "Start service after install"
ExecWait '"$INSTDIR\nfs.exe" /start /quiet'
Section "System tray icon"
CreateShortCut "$SMSTARTUP\${SHORT_PROD} Console.lnk" \
"$INSTDIR\nfs.exe" "/console /quiet"
Exec '"$INSTDIR\nfs.exe" /console /quiet'
Section "Run configuration program after install"
Exec '"$INSTDIR\configure\configure.exe"'
; Uninstaller
!ifdef NFSDEMO
Function un.onUninstSuccess
ExecShell "open" ""
Section Uninstall
SetShellVarContext all
;;Call un.StopConsole
Call un.StopAndDeleteService
DetailPrint "Removing registry keys..."
DeleteRegKey HKLM "${UNINSTKEY}"
DeleteRegKey HKLM "${REGKEY}"
DeleteRegValue HKLM "${APPCOMPATLAYERS}" "$INSTDIR\nfs.exe"
DeleteRegValue HKLM "${APPCOMPATLAYERS}" "$INSTDIR\configure\configure.exe"
DetailPrint "Removing files and uninstaller..."
Rmdir /r "$INSTDIR\system-dlls"
; would have used rmdir /r $INSTDIR but the config
; file is there too and we might want to preserve it. Bleh
Delete /rebootok "$INSTDIR\files.bu"
Delete /rebootok "$INSTDIR\*.txt"
Delete /rebootok "$INSTDIR\*.dll"
Delete /rebootok "$INSTDIR\*.dxl"
Delete /rebootok "$INSTDIR\*.exe"
Delete /rebootok "$INSTDIR\*.lic"
Delete /rebootok "$INSTDIR\nfs.cfg.default"
Delete /rebootok "$INSTDIR\nsm-state"
Rmdir /r "$INSTDIR\configure"
Rmdir /r "$INSTDIR\locales"
IfFileExists "$INSTDIR\nfs.cfg" 0 no_nfs_cfg
"Would you like to preserve $INSTDIR\nfs.cfg?" \
IDYES no_nfs_cfg IDNO remove_nfs_cfg
Delete /rebootok "$INSTDIR\nfs.cfg"
; may not work if nfs.cfg was preserved.
rmdir "$INSTDIR"
; Remove directories used
RMDir /r "${SMDIR}"
RMDir /rebootok "$INSTDIR"
Delete /rebootok "$SMSTARTUP\${SHORT_PROD} Console.lnk"
Jump to Line
Something went wrong with that request. Please try again.