InstType $Name_InstTypeMinimum
InstType $Name_InstTypeFull
+RequestExecutionLevel user
+!addincludedir .
+!addplugindir .
+!include UAC.nsh
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; NSIS Modern User Interface configuration ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
- !define MUI_FINISHPAGE_RUN "$INSTDIR\vlc.exe"
+
+ Function ExecAppFile
+ Exec '$INSTDIR\vlc.exe'
+ FunctionEnd
+
+ Function AppRunAs
+ !insertmacro UAC.CallFunctionAsUser ExecAppFile
+ FunctionEnd
+
+ !define MUI_FINISHPAGE_RUN
+ !define MUI_FINISHPAGE_RUN_FUNCTION AppRunAs
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README.txt"
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_LINK $Link_VisitWebsite
; 3. Delete prefs and cache ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+Function ExecCacheGen
+ ExecWait "$INSTDIR\vlc-cache-gen.exe $APPDATA\\VideoLAN\\VLC"
+FunctionEnd
+
!macro gencache
SetShellVarContext all
CreateDirectory "$APPDATA\\VideoLAN"
CreateDirectory "$APPDATA\\VideoLAN\\VLC"
- ExecWait "$INSTDIR\vlc-cache-gen.exe $APPDATA\\VideoLAN\\VLC"
+ !insertmacro UAC.CallFunctionAsUser ExecCacheGen
SetShellVarContext current
!macroend
;;; Start function
Function .onInit
+
+UAC_Elevate:
+ UAC::RunElevated
+ StrCmp 1223 $0 UAC_ElevationAborted
+ StrCmp 0 $0 0 UAC_Err
+ StrCmp 1 $1 0 UAC_Success
+ Quit
+
+UAC_Err:
+ MessageBox mb_iconstop "Unable to elevate, error $0"
+ Abort
+
+UAC_ElevationAborted:
+ MessageBox mb_iconstop "This installer requires admin access, aborting!"
+ Abort
+
+UAC_Success:
+ StrCmp 1 $3 +4
+ StrCmp 3 $1 0 UAC_ElevationAborted
+ MessageBox mb_iconstop "This installer requires admin access, try again"
+ goto UAC_Elevate
!insertmacro MUI_LANGDLL_DISPLAY
!include "languages\english.nsh"
FunctionEnd
+Function .OnInstFailed
+ UAC::Unload
+FunctionEnd
+
+Function .OnInstSuccess
+ UAC::Unload
+FunctionEnd
;; End function
Section -Post
WriteUninstaller "$INSTDIR\uninstall.exe"
!insertmacro MUI_DESCRIPTION_TEXT ${SEC92} $Desc_Section92
!insertmacro MUI_UNFUNCTION_DESCRIPTION_END
-;Function un.onUninstSuccess
-; HideWindow
-; MessageBox MB_ICONINFORMATION|MB_OK \
-; "$(^Name) was successfully removed from your computer."
-;FunctionEnd
+Function un.OnUnInstFailed
+ UAC::Unload
+FunctionEnd
+
+Function un.OnUnInstSuccess
+ UAC::Unload
+ Delete "$INSTDIR\UAC.dll"
+FunctionEnd
Function un.onInit
+
+UAC_Elevate:
+ UAC::RunElevated
+ StrCmp 1223 $0 UAC_ElevationAborted
+ StrCmp 0 $0 0 UAC_Err
+ StrCmp 1 $1 0 UAC_Success
+ Quit
+
+UAC_Err:
+ MessageBox mb_iconstop "Unable to elevate, error $0"
+ Abort
+
+UAC_ElevationAborted:
+ MessageBox mb_iconstop "This installer requires admin access, aborting!"
+ Abort
+
+UAC_Success:
+ StrCmp 1 $3 +4
+ StrCmp 3 $1 0 UAC_ElevationAborted
+ MessageBox mb_iconstop "This installer requires admin access, try again"
+ goto UAC_Elevate
+
!insertmacro MUI_UNGETLANGUAGE
!include "languages\english.nsh"