Newbie question
I'm new to NSIS (couple of days). It seems to be a great tool thus far. I seem to have everything working except for one issue. I'm installing a 32 bit legacy app on Windows 7x64. I cannot get the InstallLib macro to write files to $SYSDIR or "$COMMONFILES\Microsoft Shared\VFP".
I think I have set RequestExecutionLevel and used UAC_RunElevated correctly?? from what I found in the examples and forums. The File statement does succeed in creating a file in the SysWOW64 folder, so $SYSDIR is working for it. It also creates the $INSTDIR folder under Program Files x64 and populates the files. There are no error messages; the $SYSDIR files simply do not get created. I seem to be close but I must be missing something simple - either a setting, system variable, or I may not fully understand the coding order required.
I am listing the code (less uninstall) in hopes that someone can look at it and point me in the right direction.
; Script generated by the HM NIS Edit Script Wizard.
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "KOF Data System"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "KOF Company"
!define PRODUCT_WEB_SITE "http://www.zakula.com"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\kfMain.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"
; MUI 1.67 compatible ------
!include "MUI.nsh"
!include LogicLib.nsh
; Administrative priveleges
!include UAC.nsh
; 64 bit compatibility ------
!include x64.nsh ; jz
; DLL/TLB installation routine ------
!include Library.nsh ; jz
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!define MUI_LICENSEPAGE_CHECKBOX
!insertmacro MUI_PAGE_LICENSE "g:\kof_setup_9\License.txt"
; Start menu page
var ICONS_GROUP
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "KOF Data System"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\kfMain.exe"
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\ReadMe.txt"
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
; MUI end ------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "kfSetup.exe"
InstallDir "$PROGRAMFILES\KOF"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
BrandingText 'KOF System'
ShowInstDetails show
ShowUnInstDetails show
RequestExecutionLevel none
BGGradient FF0000 0000FF 00FF00
Icon 'g:\kof_Setup_9\kof.ico'
InstProgressFlags 'smooth'
LicenseBkColor '/windows'
WindowIcon on
SetFont Tahoma 10
;;;;;;;;; FUNCTION .ONINIT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Function .onInit ; jz
; Try to setup admin priveleges for install process (COPIED EXAMPLE)
uac_tryagain:
!insertmacro UAC_RunElevated
#MessageBox mb_TopMost "0=$0 1=$1 2=$2 3=$3"
${Switch} $0
${Case} 0
${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done
${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on
${If} $1 = 3 ;RunAs completed successfully, but with a non-admin user
MessageBox mb_IconExclamation|mb_TopMost|mb_SetForeground "This installer requires admin access, try again" /SD IDNO IDOK uac_tryagain IDNO 0
${EndIf}
;fall-through and die
${Case} 1223
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "This installer requires admin privileges, aborting!"
Quit
${Case} 1062
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!"
Quit
${Default}
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate , error $0"
Quit
${EndSwitch}
; Set up and display splash screen w/fade-in
SetOutPath $TEMP
File /oname=$PLUGINSDIR\SplashTmp.bmp "g:\kof_setup_9\KOF_SetupSplash1.bmp"
advsplash::show 1000 850 500 -1 $PLUGINSDIR\SplashTmp
; To determine the system folders (32 bit or 64 bit) at runtime
${EnableX64FSRedirection}
StrCpy $INSTDIR "$PROGRAMFILES\KOF"
FunctionEnd
;;;;;;;;; FUNCTION .ONINIT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;; FUNCTION .ONGUIEND ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Function .onGuiEnd ; jz
; Run PostgreSql ODBC 8.3 install application, and then delete it
ExecWait '"msiexec" /i "$INSTDIR\psql_odbc_8_3.msi"' ; PostgreSQL ODBC installer
;Delete "$INSTDIR\psql_odbc_8_3.msi"
; If Chosen by user, display the readme file
MessageBox MB_YESNO|MB_ICONQUESTION "Do you wish to view the ReadMe file now?" IDNO false
!system '"$WINDIR\notepad.exe" "$INSTDIR\ReadMe.txt"'
false:
MessageBox MB_YESNO|MB_ICONQUESTION "The computer must be rebooted for settings to take effect. Do you wish to reboot your computer now?" IDNO false2
Reboot
false2:
FunctionEnd
;;;;;;;;; FUNCTION .ONGUIEND ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; SECTION SEC01 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Section "MainSection" SEC01
SetOverwrite ifnewer
; Copy into $INSTDIR
SetOutPath "$INSTDIR"
; Copy app-specific files
File "g:\kof_setup_9\kfMain.exe"
File "g:\kof_setup_9\Config.fpw"
File "g:\kof_setup_9\AppStart.app"
; Dummy app to trigger "get updated build" process
File "g:\kof_setup_9\kf0000.app"
File "g:\kof_setup_9\AppInfo.ini"
File "g:\kof_setup_9\ReportOutput.app"
File "g:\kof_setup_9\ReportPreview.app"
File "g:\kof_setup_9\ReportBuilder.app"
File "g:\kof_setup_9\FoxTools.fll"
File "g:\kof_setup_9\MD5.fll"
File "g:\kof_setup_9\FoxUser.dbf"
File "g:\kof_setup_9\FoxUser.fpt"
File "g:\kof_setup_9\vfpAlert.exe"
; Copy necessary ODBC driver installation package
File "g:\kof_setup_9\PostgresOdbcDriver\psql_odbc_8_3.msi"
; Copy files needed for Dazzle interface is to be shipping computer
CreateDirectory "$INSTDIR\Dazzle"
SetOutPath "$INSTDIR\Dazzle"
File "g:\kof_setup_9\Dazzle\Dazzle_BoundPrint.lyt"
File "g:\kof_setup_9\Dazzle\Dazzle_FirstClass.lyt"
File "g:\kof_setup_9\Dazzle\Dazzle_MediaMail.lyt"
File "g:\kof_setup_9\Dazzle\Dazzle_ParcelPost.lyt"
File "g:\kof_setup_9\Dazzle\Dazzle_PriorityMail.lyt"
File "g:\kof_setup_9\Dazzle\Dazzle_APO_FPO_ShipLabel.lyt"
File "g:\kof_setup_9\Dazzle\Dazzle_Lg_Pri_Intl_ShipLbl.lyt"
File "g:\kof_setup_9\Dazzle\KofPackage1.lyt"
File "g:\kof_setup_9\Dazzle\DazzleAddressCodes.txt"
File "g:\kof_setup_9\Dazzle\DazzlePostalServices.txt"
File "g:\kof_setup_9\Dazzle\KofDazzle_ReadMe.txt"
; Copy into $INSTDIR\BarCode_Scanner
CreateDirectory "$INSTDIR\BarCode_Scanner"
SetOutPath "$INSTDIR\BarCode_Scanner"
File "g:\kof_setup_9\BarCode_Scanner\Free3of9.txt"
File "g:\kof_setup_9\BarCode_Scanner\kf_ScannerSetup.txt"
File "g:\kof_setup_9\BarCode_Scanner\Xi2000_Manual.pdf"
File "g:\kof_setup_9\BarCode_Scanner\Xi2000_Spec.pdf"
; Copy into $FONTS
SetOutPath "$FONTS"
File "g:\kof_setup_9\BarCode_Scanner\Free3of9.ttf"
File "g:\kof_setup_9\BarCode_Scanner\Fre3of9x.ttf"
SetOutPath "$SYSDIR"
; Try to use a straight file write to sysdir
File "g:\kof_setup_9\TestSysDirFile.txt"
; Install in $COMMONFILES or $SYSDIR
!insertmacro InstallLib DLL SHARED REBOOT_PROTECTED "g:\kof_setup_9\MsVcr71.dll" $SYSDIR $COMMONFILES
CreateDirectory "$COMMONFILES\Microsoft Shared\VFP"
!insertmacro InstallLib DLL SHARED REBOOT_PROTECTED "g:\kof_setup_9\GdiPlus.dll" "$COMMONFILES\Microsoft Shared\VFP" $COMMONFILES
!insertmacro InstallLib REGDLL SHARED REBOOT_PROTECTED "g:\kof_setup_9\vfp9R.dll" "$COMMONFILES\Microsoft Shared\VFP" $COMMONFILES
!insertmacro InstallLib REGDLL SHARED REBOOT_PROTECTED "g:\kof_setup_9\vfp9T.dll" "$COMMONFILES\Microsoft Shared\VFP" $COMMONFILES
!insertmacro InstallLib DLL SHARED REBOOT_PROTECTED "g:\kof_setup_9\vfp9Renu.dll" "$COMMONFILES\Microsoft Shared\VFP" $COMMONFILES
!insertmacro InstallLib REGEXE SHARED REBOOT_PROTECTED "g:\kof_setup_9\FoxHHelp9.exe" "$COMMONFILES\Microsoft Shared\VFP" $COMMONFILES
!insertmacro InstallLib DLL SHARED REBOOT_PROTECTED "g:\kof_setup_9\FoxHHelpPs9.dll" "$COMMONFILES\Microsoft Shared\VFP" $COMMONFILES
; Already available in windows
;!insertmacro InstallLib DLL SHARED REBOOT_PROTECTED "g:\kof_setup_9\MsXml3.dll" $SYSDIR $COMMONFILES
;!insertmacro InstallLib DLL SHARED REBOOT_PROTECTED "g:\kof_setup_9\MsXml3r.dll" $SYSDIR $COMMONFILES
!insertmacro InstallLib DLL SHARED REBOOT_PROTECTED "g:\kof_setup_9\MsXml3a.dll" $SYSDIR $COMMONFILES
!insertmacro InstallLib REGDLL SHARED REBOOT_PROTECTED "g:\kof_setup_9\MsXml4.dll" $SYSDIR $COMMONFILES
!insertmacro InstallLib REGDLL SHARED REBOOT_PROTECTED "g:\kof_setup_9\MsXml4r.dll" $SYSDIR $COMMONFILES
!insertmacro InstallLib REGDLL SHARED REBOOT_PROTECTED "g:\kof_setup_9\Filer.dll" "$COMMONFILES\Microsoft Shared\VFP" $COMMONFILES
!insertmacro InstallLib DLL NOTSHARED REBOOT_PROTECTED "g:\kof_setup_9\DibApi32.dll" $INSTDIR $COMMONFILES
; Create the Shortcuts
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
SetShellVarContext all
CreateDirectory "$SMPROGRAMS\KOF Data System"
CreateShortCut "$SMPROGRAMS\KOF Data System\KOF.lnk" "$INSTDIR\kfMain.exe"
CreateShortCut "$DESKTOP\KOF.lnk" "$INSTDIR\kfMain.exe"
CreateShortCut "$QUICKLAUNCH\KOF.lnk" "$INSTDIR\kfMain.exe"
SetShellVarContext current
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
;;;;;;; SECTION SEC01 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;