Extending
Extending PortableApps.comLauncher.nsi
Extending
Extending the PortableApps.comLauncher.nsi
file is not hard but you do have to know what you're doing. I would recommend having a firm grasp on NSIS and it's syntax before trying to extend PAL. If you do know what you're doing and would like to use some of the code I have written to extend PortableApps.comLauncher.nsi
then you're in the right place.
Defines
Below you can find the code I wrote to extend PortableApps.comLauncher.nsi
which is used to read all the !define
commands in the Launcher section of the custom.nsh
for use in PortableApps.comLauncher.nsi
. Using the code below you will not have to edit the PortableApps.comLauncher.nsi
file anymore (If you're using a build by FukenGruven). You can read this for more on what I'm talking about.
Attention
You should know that this is meant for a special build of PAL which is made by FukenGruven. You can however use this method in your own source code if you know what you're doing.Also, you need to use NSISPortable 3.0+ in order for this to properly compile. You can find a special version of NSISPortable with support for FukenGruven's build of PAL at the bottom of this page.
Note
In order for this to work thecustom.nsh
Launcher section needs to have the same !define
you would see in the Launcher.nsi
file but with ;
and a boolean value of true at the end. So if it was !define UAC
in the Launcher.nsi
file then in the custom.nsh
file it would be ;!define UAC true
. Make sure to have it commented in the custom.nsh
file otherwise this won't work.
;=# Define where the custom.nsh file is.
!define NSH `${PACKAGE}\App\AppInfo\Launcher\custom.nsh`
;=# Defines the RequestLevel for use with the manifest
; See http://softables.tk/docs/advanced/uac#manifests
!searchparse /noerrors /file `${NSH}` `;!define RequestLevel ` RequestLevel ``
!if ${RequestLevel} == USER
!define /redef RequestLevel USER
!else if ${RequestLevel} == ADMIN
!define /redef RequestLevel ADMIN
!else
!define /redef RequestLevel USER
!endif
;=== ExecAsUser
!searchparse /noerrors /file `${NSH}` `;!define Include_StdUtils.nsh ` Include_StdUtils.nsh ``
!searchparse /noerrors /file `${NSH}` `;!define ExecAsUser ` ExecAsUser ``
!if ${Include_StdUtils.nsh} == true
!define /redef Include_StdUtils.nsh ;=== Include StndUtils without ExecAsUser
!else
!ifdef Include_StdUtils.nsh
!undef Include_StdUtils.nsh
!endif
!endif
!if ${ExecAsUser} == true
!define /redef ExecAsUser ;=== For applications which need to run as normal user.
!else
!ifdef ExecAsUser
!undef ExecAsUser
!endif
!endif
;=# Read Custom Defines
; Below reads custom.nsh for the defines and sets them accordingly.
!searchparse /noerrors /file `${NSH}` `;!define RegSleep ` RegSleep ``
!searchparse /noerrors /file `${NSH}` `;!define Sleep ` Sleep ``
!searchparse /noerrors /file `${NSH}` `;!define NETCheck ` NETCheck ``
!searchparse /noerrors /file `${NSH}` `;!define SetSysWOW64 ` SetSysWOW64 ``
!searchparse /noerrors /file `${NSH}` `;!define SetAllUsersAppData ` SetAllUsersAppData ``
!searchparse /noerrors /file `${NSH}` `;!define CloseProc ` CloseProc ``
!searchparse /noerrors /file `${NSH}` `;!define DisablePAL:LanguageCustom ` DisablePAL:LanguageCustom ``
!searchparse /noerrors /file `${NSH}` `;!define DisableProgramExecSegment ` DisableProgramExecSegment ``
!searchparse /noerrors /file `${NSH}` `;!define SYSTEMWIDE_DISABLEREDIR ` SYSTEMWIDE_DISABLEREDIR ``
!searchparse /noerrors /file `${NSH}` `;!define FORCE_SYSTEMWIDE_DISABLEREDIR ` FORCE_SYSTEMWIDE_DISABLEREDIR ``
!searchparse /noerrors /file `${NSH}` `;!define RMEMPTYDIRECTORIES ` RMEMPTYDIRECTORIES ``
!searchparse /noerrors /file `${NSH}` `;!define JAVA ` JAVA ``
!searchparse /noerrors /file `${NSH}` `;!define UAC ` UAC ``
!searchparse /noerrors /file `${NSH}` `;!define XML_PLUGIN ` XML_PLUGIN ``
!searchparse /noerrors /file `${NSH}` `;!define REGISTERDLL ` REGISTERDLL ``
!searchparse /noerrors /file `${NSH}` `;!define REPLACE ` REPLACE ``
!searchparse /noerrors /file `${NSH}` `;!define TLB_FUNCTION ` TLB_FUNCTION ``
!searchparse /noerrors /file `${NSH}` `;!define FIREWALL ` FIREWALL ``
!searchparse /noerrors /file `${NSH}` `;!define NSIS_REGISTRY ` NSIS_REGISTRY ``
!searchparse /noerrors /file `${NSH}` `;!define 64.nsh ` 64.nsh ``
!searchparse /noerrors /file `${NSH}` `;!define StrRep.nsh ` StrRep.nsh ``
!searchparse /noerrors /file `${NSH}` `;!define RIF.nsh ` RIF.nsh ``
!searchparse /noerrors /file `${NSH}` `;!define Disable_Settings ` Disable_Settings ``
!searchparse /noerrors /file `${NSH}` `;!define REGISTRY ` REGISTRY ``
!searchparse /noerrors /file `${NSH}` `;!define SERVICES ` SERVICES ``
!searchparse /noerrors /file `${NSH}` `;!define DirectoriesMoveVista ` DirectoriesMoveVista ``
!searchparse /noerrors /file `${NSH}` `;!define DIRECTORIES_MOVE ` DIRECTORIES_MOVE ``
!searchparse /noerrors /file `${NSH}` `;!define FILES_MOVE ` FILES_MOVE ``
!searchparse /noerrors /file `${NSH}` `;!define FONTS_ENABLE ` FONTS_ENABLE ``
!searchparse /noerrors /file `${NSH}` `;!define LocalLow ` LocalLow ``
!searchparse /noerrors /file `${NSH}` `;!define PublicDoc ` PublicDoc ``
!searchparse /noerrors /file `${NSH}` `;!define NTFS ` NTFS ``
!searchparse /noerrors /file `${NSH}` `;!define ACL ` ACL ``
!searchparse /noerrors /file `${NSH}` `;!define ACL_DIR ` ACL_DIR ``
!searchparse /noerrors /file `${NSH}` `;!define CloseWindow ` CloseWindow ``
!searchparse /noerrors /file `${NSH}` `;!define DisableRMDirPostDirMove ` DisableRMDirPostDirMove ``
!searchparse /noerrors /file `${NSH}` `;!define GetBetween.nsh ` GetBetween.nsh ``
!searchparse /noerrors /file `${NSH}` `;!define TrimString ` TrimString ``
!searchparse /noerrors /file `${NSH}` `;!define IsFileLocked ` IsFileLocked ``
!searchparse /noerrors /file `${NSH}` `;!define INF_Install ` INF_Install ``
!searchparse /noerrors /file `${NSH}` `;!define SSDL ` SSDL ``
!searchparse /noerrors /file `${NSH}` `;!define FileCleanup ` FileCleanup ``
!searchparse /noerrors /file `${NSH}` `;!define Include_WordRep ` Include_WordRep ``
!searchparse /noerrors /file `${NSH}` `;!define Include_LineWrite.nsh ` Include_LineWrite.nsh ``
!searchparse /noerrors /file `${NSH}` `;!define Include_ReadLine ` Include_ReadLine ``
!searchparse /noerrors /file `${NSH}` `;!define ConFunc ` ConFunc ``
!searchparse /noerrors /file `${NSH}` `;!define CompareVersions ` CompareVersions ``
!searchparse /noerrors /file `${NSH}` `;!define Include_WinMessages.nsh ` Include_WinMessages.nsh ``
!searchparse /noerrors /file `${NSH}` `;!define DISABLEFSR ` DISABLEFSR ``
!searchparse /noerrors /file `${NSH}` `;!define RegCopy ` RegCopy ``
;=# Set Custom Defines
; Below checks if the defines are true and redefines them accordingly.
!if ${RegSleep} == true
!define /redef RegSleep 50 ;=== Sleep value for RegistryValueWrite. else function is innaccurate.
!else
!ifdef RegSleep
!undef RegSleep
!endif
!endif
!if ${Sleep} == true
!define /redef Sleep 500 ;=== Sleep value for RegistryValueWrite. else function is innaccurate.
!else
!ifdef Sleep
!undef Sleep
!endif
!endif
!if ${NETCheck} == true
!define /redef NETCheck ;=== function to check for .NET Framework.
!else
!ifdef NETCheck
!undef NETCheck
!endif
!endif
!if ${SetSysWOW64} == true
!define /redef SetSysWOW64 ;=== Sets $SysWOW64 variable.
!else
!ifdef SetSysWOW64
!undef SetSysWOW64
!endif
!endif
!if ${SetAllUsersAppData} == true
!define /redef SetAllUsersAppData ;=== Sets $ALLUSERSAPPDATA variable.
!else
!ifdef SetAllUsersAppData
!undef SetAllUsersAppData
!endif
!endif
!if ${CloseProc} == true
!define /redef CloseProc
!else
!ifdef CloseProc
!undef CloseProc
!endif
!endif
!if ${DisablePAL:LanguageCustom} == true
!define /redef DisablePAL:LanguageCustom
!else
!ifdef DisablePAL:LanguageCustom
!undef DisablePAL:LanguageCustom
!endif
!endif
!if ${DisableProgramExecSegment} == true
!define /redef DisableProgramExecSegment ;=== for apps. which require $ProgramExecutable built in !macro RunAsAdmin
!else
!ifdef DisableProgramExecSegment
!undef DisableProgramExecSegment
!endif
!endif
!if ${SYSTEMWIDE_DISABLEREDIR} == true
!define /redef SYSTEMWIDE_DISABLEREDIR
!else
!ifdef SYSTEMWIDE_DISABLEREDIR
!undef SYSTEMWIDE_DISABLEREDIR
!endif
!endif
!if ${FORCE_SYSTEMWIDE_DISABLEREDIR} == true
!define /redef FORCE_SYSTEMWIDE_DISABLEREDIR ;=== checks using $Bit
!else
!ifdef FORCE_SYSTEMWIDE_DISABLEREDIR
!undef FORCE_SYSTEMWIDE_DISABLEREDIR
!endif
!endif
!if ${RMEMPTYDIRECTORIES} == true
!define /redef RMEMPTYDIRECTORIES ;=== enable for the [DirectoriesCleanupIfEmpty] section in launcher.ini
!else
!ifdef RMEMPTYDIRECTORIES
!undef RMEMPTYDIRECTORIES
!endif
!endif
!if ${JAVA} == true
!define /redef JAVA ;=== enable for Java support
!else
!ifdef JAVA
!undef JAVA
!endif
!endif
!if ${UAC} == true
!define /redef UAC ;=== enable for administrative privileges
!else
!ifdef UAC
!undef UAC
!endif
!endif
!if ${XML_PLUGIN} == true
!define /redef XML_PLUGIN ;=== endable for XML functionality
!else
!ifdef XML_PLUGIN
!undef XML_PLUGIN
!endif
!endif
!if ${REGISTERDLL} == true
!define /redef REGISTERDLL ;=== enable for registering DLLs macros
!else
!ifdef REGISTERDLL
!undef REGISTERDLL
!endif
!endif
!if ${REPLACE} == true
!define /redef REPLACE
!else
!ifdef REPLACE
!undef REPLACE
!endif
!endif
!if ${TLB_FUNCTION} == true
!define /redef TLB_FUNCTION
!else
!ifdef TLB_FUNCTION
!undef TLB_FUNCTION
!endif
!endif
!if ${FIREWALL} == true
!define /redef FIREWALL
!else
!ifdef FIREWALL
!undef FIREWALL
!endif
!endif
!if ${NSIS_REGISTRY} == true
!define /redef NSIS_REGISTRY ;=== enable for copying/moving registry branches
!else
!ifdef NSIS_REGISTRY
!undef NSIS_REGISTRY
!endif
!endif
!if ${64.nsh} == true
!define /redef 64.nsh ;=== enable for including the 64.nsh plugin
!else
!ifdef 64.nsh
!undef 64.nsh
!endif
!endif
!if ${StrRep.nsh} == true
!include StrRep.nsh
!else
!ifdef StrRep.nsh
!undef StrRep.nsh
!endif
!endif
!if ${RIF.nsh} == true
!include RIF.nsh
!else
!ifdef RIF.nsh
!undef RIF.nsh
!endif
!endif
!if ${Disable_Settings} == true
!define /redef Disable_Settings
!else
!ifdef Disable_Settings
!undef Disable_Settings
!endif
!endif
!if ${REGISTRY} == true
!define /redef REGISTRY ;=== enable for registry
!else
!ifdef REGISTRY
!undef REGISTRY
!endif
!endif
!if ${SERVICES} == true
!define /redef SERVICES ;=== enable for services
!else
!ifdef SERVICES
!undef SERVICES
!endif
!endif
!if ${DirectoriesMoveVista} == true
!define /redef DirectoriesMoveVista ;=== for Vista + only. ie. LocalAppDataLow
!else
!ifdef DirectoriesMoveVista
!undef DirectoriesMoveVista
!endif
!endif
!if ${DIRECTORIES_MOVE} == true
!define /redef DIRECTORIES_MOVE ;=== enable for the [DirectoriesMove] section in launcher.ini
!else
!ifdef DIRECTORIES_MOVE
!undef DIRECTORIES_MOVE
!endif
!endif
!if ${FILES_MOVE} == true
!define /redef FILES_MOVE ;=== enable for the [FilesMove] section in launcher.ini
!else
!ifdef FILES_MOVE
!undef FILES_MOVE
!endif
!endif
!if ${FONTS_ENABLE} == true
!define /redef FONTS_ENABLE
!else
!ifdef FONTS_ENABLE
!undef FONTS_ENABLE
!endif
!endif
!if ${LocalLow} == true
!define /redef LocalLow
!else
!ifdef LocalLow
!undef LocalLow
!endif
!endif
!if ${PublicDoc} == true
!define /redef PublicDoc
!else
!ifdef PublicDoc
!undef PublicDoc
!endif
!endif
!if ${NTFS} == true
!define /redef NTFS ;=== enable for junctions
!else
!ifdef NTFS
!undef NTFS
!endif
!endif
!if ${ACL} == true
!define /redef ACL
!else
!ifdef ACL
!undef ACL
!endif
!endif
!if ${ACL_DIR} == true
!define /redef ACL_DIR
!else
!ifdef ACL_DIR
!undef ACL_DIR
!endif
!endif
!if ${CloseWindow} == true
!define /redef CloseWindow ;=== enable if using ${If} ${FileLocked}
!else
!ifdef CloseWindow
!undef CloseWindow
!endif
!endif
!if ${DisableRMDirPostDirMove} == true
!define /redef DisableRMDirPostDirMove ;=== enable for SRWareIron
!else
!ifdef DisableRMDirPostDirMove
!undef DisableRMDirPostDirMove
!endif
!endif
!if ${GetBetween.nsh} == true
!define /redef GetBetween.nsh
!else
!ifdef GetBetween.nsh
!undef GetBetween.nsh
!endif
!endif
!if ${TrimString} == true
!define /redef TrimString ;=== enable for UAC
!else
!ifdef TrimString
!undef TrimString
!endif
!endif
!if ${IsFileLocked} == true
!define /redef IsFileLocked ;=== enable ${If} ${FileLocked} / ${IfNot} ${FileLocked}
!else
!ifdef IsFileLocked
!undef IsFileLocked
!endif
!endif
!if ${INF_Install} == true
!define /redef INF_Install ;=== enable !macros for .inf installation
!else
!ifdef INF_Install
!undef INF_Install
!endif
!endif
!if ${SSDL} == true
!define /redef SSDL ;=== enable for SSDL
!else
!ifdef SSDL
!undef SSDL
!endif
!endif
!if ${FileCleanup} == true
!define /redef FileCleanup ;=== enable FilesCleanup
!else
!ifdef FileCleanup
!undef FileCleanup
!endif
!endif
!if ${Include_WordRep} == true
!define /redef Include_WordRep ;=== enable WordRep & WordRepSs (same as ${WordReplace})
!else
!ifdef Include_WordRep
!undef Include_WordRep
!endif
!endif
!if ${Include_LineWrite.nsh} == true
!define /redef Include_LineWrite.nsh ;=== include LineWrite.nsh
!else
!ifdef Include_LineWrite.nsh
!undef Include_LineWrite.nsh
!endif
!endif
!if ${Include_ReadLine} == true
!define /redef Include_ReadLine ;=== enable ReadLine Function (same as LineRead)
!else
!ifdef Include_ReadLine
!undef Include_ReadLine
!endif
!endif
!if ${ConFunc} == true
!define /redef ConFunc ;=== enable ConfigWrite(s), ConfigRead(s) Functions.
!else
!ifdef ConFunc
!undef ConFunc
!endif
!endif
!if ${CompareVersions} == true
!define /redef CompareVersions ;=== enable VersionCompare Function.
!else
!ifdef CompareVersions
!undef CompareVersions
!endif
!endif
!if ${Include_WinMessages.nsh} == true
!define /redef Include_WinMessages.nsh ;=== include WinMessages.nsh
!else
!ifdef Include_WinMessages.nsh
!undef Include_WinMessages.nsh
!endif
!endif
!ifdef REGISTRY
!if ${DISABLEFSR} == true
!define /redef DISABLEFSR ;=== Disable redirection
!else
!ifdef DISABLEFSR
!undef DISABLEFSR
!endif
!endif
!if ${RegCopy} == true
!define /redef RegCopy ;=== Enable RegistryCopy
!else
!ifdef RegCopy
!undef RegCopy
!endif
!endif
!endif
Specifications
Below is the code I wrote which will read the AppInfo.ini
for certain keys and their values which can then be used with VIAddVersionKey
and various other defines throughout the custom.nsh
file.
;=# Application Specifications
; Below reads the AppInfo.ini for the defines
!searchparse /noerrors /file ${PACKAGE}\App\AppInfo\appinfo.ini `AppID=` APPNAME ``
!searchreplace APP "${APPNAME}" "Portable" ""
!searchreplace APP64 "${APPNAME}" "Portable" "64"
!searchparse /noerrors /file ${PACKAGE}\App\AppInfo\appinfo.ini `Name=` PORTABLEAPPNAME ``
!searchreplace FULLNAME "${PORTABLEAPPNAME}" " Portable" ""
!define APPDIR `$EXEDIR\App\${APP}`
;!define APPDIR64 `$EXEDIR\App\${APP64}`
!define APPINFO `$EXEDIR\App\AppInfo`
!define DATA `$EXEDIR\Data`
!define SET `${DATA}\settings`
!define DEFDATA `$EXEDIR\App\DefaultData`
!define DEFSET `${DEFDATA}\settings`
!define LAUNCHDIR `${APPINFO}\Launcher`
!define LAUNCHER `${LAUNCHDIR}\${APPNAME}.ini`
!define LAUNCHER2 `$PLUGINSDIR\launcher.ini`
!define RUNTIME `${DATA}\PortableApps.comLauncherRuntimeData-${APPNAME}.ini`
!define RUNTIME2 `$PLUGINSDIR\runtimedata.ini`
!define SETINI `${SET}\${APPNAME}Settings.ini`
!define CONFIG `$EXEDIR\${APPNAME}.ini`
!define OTHER `$EXEDIR\Other`
;=# Branding
; If certain information is not found in the AppInfo.ini it will
; stop compiling and alerts the user of the missing information.
!searchparse /noerrors /file ${PACKAGE}\App\AppInfo\appinfo.ini `Trademarks=` TRADEMARK ``
!searchparse /noerrors /file ${PACKAGE}\App\AppInfo\appinfo.ini `Publisher=` PUBLISHER ``
!searchparse /noerrors /file ${PACKAGE}\App\AppInfo\appinfo.ini `PackageVersion=` PACKAGE_VERSION ``
!searchparse /noerrors /file ${PACKAGE}\App\AppInfo\appinfo.ini `Start=` OUTFILE ``
${!echo} `Specifying program details and setting options...`
Name `${PORTABLEAPPNAME}`
OutFile `${PACKAGE}\${APPNAME}.exe`
Icon `${PACKAGE}\App\AppInfo\appicon.ico`
Caption `${FULLNAME}`
!ifdef PACKAGE_VERSION
!if ! ${PACKAGE_VERSION} == ""
VIProductVersion ${PACKAGE_VERSION}
VIAddVersionKey /LANG=${LANG_ENGLISH} FileVersion ${PACKAGE_VERSION}
!else
!error "The key 'PackageVersion' in AppInfo.ini needs a value! (i.e. 0.0.0.0)"
!endif
!else
!error "The key 'PackageVersion' in AppInfo.ini is missing!"
!endif
!ifdef PUBLISHER
!if ! "${PUBLISHER}" == ""
VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyName `${PUBLISHER}`
VIAddVersionKey /LANG=${LANG_ENGLISH} LegalCopyright `Copyright © ${PUBLISHER} ${YEAR}`
!else
!error "The key 'Publisher' in AppInfo.ini needs a value!"
!endif
!else
!error "The key 'Publisher' in AppInfo.ini is missing!"
!endif
!ifdef APPNAME
!if ! "${APPNAME}" == ""
VIAddVersionKey /LANG=${LANG_ENGLISH} InternalName `${APPNAME}Portable.exe`
VIAddVersionKey /LANG=${LANG_ENGLISH} OriginalFilename `${APPNAME}.exe`
!else
!error "The key 'AppID' in AppInfo.ini needs a value!"
!endif
!else
!error "The key 'AppID' in AppInfo.ini is missing!"
!endif
!ifdef FULLNAME
!if ! "${FULLNAME}" == ""
VIAddVersionKey /LANG=${LANG_ENGLISH} ProductName `${FULLNAME}`
VIAddVersionKey /LANG=${LANG_ENGLISH} FileDescription `${FULLNAME}`
!else
!error "The key 'Name' in AppInfo.ini needs a value!"
!endif
!else
!error "The key 'Name' in AppInfo.ini is missing!"
!endif
!ifdef TRADEMARK
!if ! ${TRADEMARK} == ""
VIAddVersionKey /LANG=${LANG_ENGLISH} LegalTrademarks `${TRADEMARK}`
!else
!ifdef TRADEMARK
!undef TRADEMARK
!endif
!endif
!endif
VIAddVersionKey /LANG=${LANG_ENGLISH} Comments `Developed by demon.devin (http://softables.tk/)`
VIAddVersionKey /LANG=${LANG_ENGLISH} ProductVersion Portable
Download
Here you may download thePortableApps.comLauncher.nsi
file in a zip archive with the above code already in it.Launcher.zip (356 downloads)
Here's the special build of NSISPortable that you may need to get this code working with your PAFs.
NSISPortable