]> git.sesse.net Git - vlc/blobdiff - extras/package/win32/vlc.win32.nsi.in
Win32: don't launch VLC as admin after installing
[vlc] / extras / package / win32 / vlc.win32.nsi.in
index 6afecd4b676894d019f340654655978e83a41b78..8c462a008e8e96f22ee2bb814a62e739982d57b7 100644 (file)
@@ -48,6 +48,11 @@ InstType $Name_InstTypeRecommended
 InstType $Name_InstTypeMinimum
 InstType $Name_InstTypeFull
 
+RequestExecutionLevel user
+!addincludedir .
+!addplugindir .
+!include UAC.nsh
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; NSIS Modern User Interface configuration ;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -66,6 +71,7 @@ InstType $Name_InstTypeFull
     !define MUI_WELCOMEPAGE_TITLE_3LINES
     !insertmacro MUI_PAGE_WELCOME
   ; License page
+    !define MUI_LICENSEPAGE_BUTTON $(^NextBtn)
     !insertmacro MUI_PAGE_LICENSE "COPYING.txt"
   ; Components page
     !insertmacro MUI_PAGE_COMPONENTS
@@ -74,7 +80,17 @@ InstType $Name_InstTypeFull
   ; 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
@@ -147,10 +163,10 @@ NoBackup:
   WriteRegStr HKCR "VLC$R0\DefaultIcon" "" '"$INSTDIR\vlc.exe",0'
 
 ;;; Vista Only part
-  ; Vista detection
+  ; Vista and above detection
   ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
-  StrCpy $R2 $R1 3
-  StrCmp $R2 '6.0' ForVista ToEnd
+  StrCpy $R2 $R1 1
+  StrCmp $R2 '6' ForVista ToEnd
 ForVista:
   WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities\FileAssociations" "$R0" "VLC$R0"
 
@@ -218,6 +234,7 @@ FunctionEnd
   !insertmacro ${_action} ".oma"
   !insertmacro ${_action} ".oga"
   !insertmacro ${_action} ".spx"
+  !insertmacro ${_action} ".tta"
   !insertmacro ${_action} ".wav"
   !insertmacro ${_action} ".wma"
   !insertmacro ${_action} ".wv"
@@ -253,6 +270,7 @@ FunctionEnd
   !insertmacro ${_action} ".rmvb"
   !insertmacro ${_action} ".ts"
   !insertmacro ${_action} ".vob"
+  !insertmacro ${_action} ".vro"
   !insertmacro ${_action} ".wmv"
 !macroend
 
@@ -260,8 +278,10 @@ FunctionEnd
   !insertmacro ${_action} ".asx"
   !insertmacro ${_action} ".bin"
   !insertmacro ${_action} ".cue"
+  !insertmacro ${_action} ".ifo"
   !insertmacro ${_action} ".m3u"
   !insertmacro ${_action} ".pls"
+  !insertmacro ${_action} ".sdp"
   !insertmacro ${_action} ".vlc"
   !insertmacro ${_action} ".xspf"
 !macroend
@@ -309,6 +329,18 @@ FunctionEnd
 ; 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"
+  !insertmacro UAC.CallFunctionAsUser ExecCacheGen
+  SetShellVarContext current
+!macroend
+
 !macro delprefs
   StrCpy $0 0
   !define Index 'Line${__LINE__}'
@@ -326,6 +358,9 @@ FunctionEnd
     Goto "${Index}-Loop"
   "${Index}-End:"
   !undef Index
+  SetShellVarContext all
+  RMDir /r "$APPDATA\\VideoLAN"
+  SetShellVarContext current
 !macroend
 
 ;;;;;;;;;;;;;;;
@@ -409,6 +444,7 @@ Section $Name_Section01 SEC01
   ; VLC.exe, libvlc.dll
   !insertmacro InstallFile vlc.exe
   !insertmacro InstallFile vlc.exe.manifest
+  !insertmacro InstallFile vlc-cache-gen.exe
 
   ; All dlls
   !insertmacro InstallFile *.dll
@@ -423,6 +459,7 @@ Section $Name_Section01 SEC01
 @BUILD_SKINS_TRUE@   !insertmacro InstallFolder skins
 @BUILD_HTTPD_TRUE@   !insertmacro InstallFolder http
 @BUILD_LUA_TRUE@     !insertmacro InstallFolder lua
+  !insertmacro gencache
 
 
   ; URLs
@@ -438,7 +475,7 @@ Section $Name_Section01 SEC01
 
   !insertmacro CloseUninstallLog
 
-  ; Add VLC to "recomended programs" for the following extensions
+  ; Add VLC to "recommended programs" for the following extensions
   WriteRegStr HKCR Applications\vlc.exe "" ""
   WriteRegStr HKCR Applications\vlc.exe "FriendlyAppName" "VLC media player"
   WriteRegStr HKCR Applications\vlc.exe\shell\Open "" $ContextMenuEntry_PlayWith
@@ -446,16 +483,21 @@ Section $Name_Section01 SEC01
     '"$INSTDIR\vlc.exe" --started-from-file "%1"'
   !insertmacro MacroAllExtensions WriteRegStrSupportedTypes
 
-; Vista Registration
-  ; Vista detection
+; Windows default programs Registration
+  ; Vista and above detection
   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
-  StrCpy $R1 $R0 3
-  StrCmp $R1 '6.0' lbl_vista lbl_done
+  StrCpy $R1 $R0 1
+  StrCmp $R1 '6' lbl_vista lbl_done
 
   lbl_vista:
   WriteRegStr HKLM "Software\RegisteredApplications" "VLC" "Software\Clients\Media\VLC\Capabilities"
   WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities" "ApplicationName" "VLC media player"
   WriteRegStr HKLM "Software\Clients\Media\VLC\Capabilities" "ApplicationDescription" "VLC - The video swiss knife"
+  WriteRegStr HKLM "Software\Clients\Media\VLC" "" "VLC media player"
+  WriteRegStr HKLM "Software\Clients\Media\VLC\InstallInfo" "HideIconsCommand" "$\"$INSTDIR\spad-setup.exe$\" /HideIcons /S"
+  WriteRegStr HKLM "Software\Clients\Media\VLC\InstallInfo" "ShowIconsCommand" "$\"$INSTDIR\spad-setup.exe$\" /ShowIcons /S"
+  WriteRegStr HKLM "Software\Clients\Media\VLC\InstallInfo" "ReinstallCommand" "$\"$INSTDIR\spad-setup.exe$\" /Reinstall /S"
+  WriteRegDWORD HKLM "Software\Clients\Media\VLC\InstallInfo" "IconsVisible" 0x001
 
   lbl_done:
 SectionEnd
@@ -641,10 +683,32 @@ SectionEnd
 
 ;;; 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"
   StrCmp $LANGUAGE ${LANG_FRENCH} French 0
+  StrCmp $LANGUAGE ${LANG_GERMAN} German 0
   StrCmp $LANGUAGE ${LANG_ITALIAN} Italian 0
   StrCmp $LANGUAGE ${LANG_HUNGARIAN} Hungarian 0
   StrCmp $LANGUAGE ${LANG_ROMANIAN} Romanian 0
@@ -659,6 +723,9 @@ Function .onInit
   French:
   !include "languages\french.nsh"
   Goto EndLanguageCmp
+  German:
+  !include "languages\german.nsh"
+  Goto EndLanguageCmp
   Italian:
   !include "languages\italian.nsh"
   Goto EndLanguageCmp
@@ -707,6 +774,13 @@ Function .onInit
 
 FunctionEnd
 
+Function .OnInstFailed
+    UAC::Unload
+FunctionEnd
+
+Function .OnInstSuccess
+    UAC::Unload
+FunctionEnd
 ;; End function
 Section -Post
   WriteUninstaller "$INSTDIR\uninstall.exe"
@@ -863,6 +937,7 @@ Section "un.$Name_Section91" SEC91
   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" "VLCPlayCDAudioOnArrival"
   DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival
   DeleteRegKey HKLM Software\Clients\Media\VLC
+  DeleteRegValue HKLM "Software\RegisteredApplications" "VLC"
   DeleteRegKey HKCR "VLC.MediaFile"
 
   DeleteRegKey HKLM \
@@ -888,17 +963,43 @@ SectionEnd
   !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"
   StrCmp $LANGUAGE ${LANG_FRENCH} French 0
+  StrCmp $LANGUAGE ${LANG_GERMAN} German 0
   StrCmp $LANGUAGE ${LANG_ITALIAN} Italian 0
   StrCmp $LANGUAGE ${LANG_HUNGARIAN} Hungarian 0
   StrCmp $LANGUAGE ${LANG_ROMANIAN} Romanian 0
@@ -913,6 +1014,9 @@ Function un.onInit
   French:
   !include "languages\french.nsh"
   Goto EndLanguageCmp
+  German:
+  !include "languages\german.nsh"
+  Goto EndLanguageCmp
   Italian:
   !include "languages\italian.nsh"
   Goto EndLanguageCmp