diff --git a/admin/win/tomahawk.nsi b/admin/win/tomahawk.nsi index 694e3ae48..18ed8eb88 100755 --- a/admin/win/tomahawk.nsi +++ b/admin/win/tomahawk.nsi @@ -4,6 +4,7 @@ ; Some installer script options (comment-out options not required) ;----------------------------------------------------------------------------- ;!define OPTION_LICENSE_AGREEMENT +;!define OPTION_UAC_ENHANCED !define OPTION_SECTION_SC_START_MENU !define OPTION_SECTION_SC_DESKTOP !define OPTION_SECTION_SC_QUICK_LAUNCH @@ -57,10 +58,17 @@ InstType Full InstType Minimal CRCCheck On SetCompressor /SOLID lzma -;RequestExecutionLevel user ;Using the UAC plugin. ReserveFile tomahawk.ini ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll" +;The UAC plugin provides an elevated user. +;Otherwise request admin level here. +!ifdef OPTION_UAC_PLUGIN_ENHANCED + RequestExecutionLevel user +!else + RequestExecutionLevel admin +!endif + ;----------------------------------------------------------------------------- ; Include some required header files. ;----------------------------------------------------------------------------- @@ -71,7 +79,9 @@ ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll" !include Memento.nsh ;Remember user selections. !include WinVer.nsh ;Windows version detection. !include WordFunc.nsh ;Used by VersionCompare macro function. -;!include UAC.nsh ;Used by the UAC elevation to install as user or admin. +!ifdef OPTION_UAC_PLUGIN_ENHANCED + !include UAC.nsh ;Used by the UAC elevation to install as user or admin. +!endif ;----------------------------------------------------------------------------- ; Memento selections stored in registry. @@ -136,12 +146,18 @@ UninstPage custom un.UnPageUserAppData un.UnPageUserAppDataLeave ############################################################################## Function LaunchTomahawk - ;${UAC.CallFunctionAsUser} LaunchTomahawkAsUser + !ifdef OPTION_UAC_PLUGIN_ENHANCED + ${UAC.CallFunctionAsUser} LaunchTomahawkAsUser + !else + Exec "$INSTDIR\tomahawk.exe" + !endif FunctionEnd +!ifdef OPTION_UAC_PLUGIN_ENHANCED Function LaunchTomahawkAsUser Exec "$INSTDIR\tomahawk.exe" FunctionEnd +!endif ############################################################################## # # @@ -210,10 +226,12 @@ Function PageLeaveReinstall Delete $R1 RMDir $INSTDIR no_remove_uninstaller: - StrCmp $R0 "2" 0 +3 - ;UAC::Unload - Quit + StrCmp $R0 "2" +2 0 BringToFront + !ifdef OPTION_UAC_PLUGIN_ENHANCED + UAC::Unload + Quit + !endif reinst_done: FunctionEnd @@ -473,25 +491,27 @@ Function .onInit ${MementoSectionRestore} - ;UAC_Elevate: - ;UAC::RunElevated - ;StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user? - ;StrCmp 0 $0 0 UAC_Err ; Error? - ;StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper? - ;Quit - - ;UAC_Err: - ;MessageBox MB_ICONSTOP "Unable to elevate, error $0" - ;Abort - - ;UAC_ElevationAborted: - ;Abort - - ;UAC_Success: - ;StrCmp 1 $3 +4 ;Admin? - ;StrCmp 3 $1 0 UAC_ElevationAborted ;Try again? - ;MessageBox MB_ICONSTOP "This installer requires admin access, try again" - ;goto UAC_Elevate + !ifdef OPTION_UAC_PLUGIN_ENHANCED + UAC_Elevate: + UAC::RunElevated + StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user? + StrCmp 0 $0 0 UAC_Err ; Error? + StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper? + Quit + + UAC_Err: + MessageBox MB_ICONSTOP "Unable to elevate, error $0" + Abort + + UAC_ElevationAborted: + Abort + + UAC_Success: + StrCmp 1 $3 +4 ;Admin? + StrCmp 3 $1 0 UAC_ElevationAborted ;Try again? + MessageBox MB_ICONSTOP "This installer requires admin access, try again" + goto UAC_Elevate + !endif ;Prevent multiple instances. System::Call 'kernel32::CreateMutexA(i 0, i 0, t "tomahawkInstaller") i .r1 ?e' @@ -503,11 +523,15 @@ FunctionEnd Function .onInstSuccess ${MementoSectionSave} - ;UAC::Unload ;Must call unload! + !ifdef OPTION_UAC_PLUGIN_ENHANCED + UAC::Unload ;Must call unload! + !endif FunctionEnd Function .onInstFailed - ;UAC::Unload ;Must call unload! + !ifdef OPTION_UAC_PLUGIN_ENHANCED + UAC::Unload ;Must call unload! + !endif FunctionEnd ############################################################################## @@ -517,26 +541,27 @@ FunctionEnd ############################################################################## Function un.onInit + !ifdef OPTION_UAC_PLUGIN_ENHANCED + UAC_Elevate: + UAC::RunElevated + StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user? + StrCmp 0 $0 0 UAC_Err ; Error? + StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper? + Quit - ;UAC_Elevate: - ;UAC::RunElevated - ;StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user? - ;StrCmp 0 $0 0 UAC_Err ; Error? - ;StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper? - ;Quit - - ;UAC_Err: - ;MessageBox MB_ICONSTOP "Unable to elevate, error $0" - ;Abort - - ;UAC_ElevationAborted: - ;Abort - - ;UAC_Success: - ;StrCmp 1 $3 +4 ;Admin? - ;StrCmp 3 $1 0 UAC_ElevationAborted ;Try again? - ;MessageBox MB_ICONSTOP "This uninstaller requires admin access, try again" - ;goto UAC_Elevate + UAC_Err: + MessageBox MB_ICONSTOP "Unable to elevate, error $0" + Abort + + UAC_ElevationAborted: + Abort + + UAC_Success: + StrCmp 1 $3 +4 ;Admin? + StrCmp 3 $1 0 UAC_ElevationAborted ;Try again? + MessageBox MB_ICONSTOP "This uninstaller requires admin access, try again" + goto UAC_Elevate + !endif ;Prevent multiple instances. System::Call 'kernel32::CreateMutexA(i 0, i 0, t "tomahawkUninstaller") i .r1 ?e' @@ -547,9 +572,13 @@ Function un.onInit FunctionEnd Function un.onUnInstSuccess - ;UAC::Unload ;Must call unload! + !ifdef OPTION_UAC_PLUGIN_ENHANCED + UAC::Unload ;Must call unload! + !endif FunctionEnd Function un.onUnInstFailed - ;UAC::Unload ;Must call unload! + !ifdef OPTION_UAC_PLUGIN_ENHANCED + UAC::Unload ;Must call unload! + !endif FunctionEnd