]> git.sesse.net Git - vlc/blobdiff - extras/package/win32/vlc.win32.nsi.in
Win32: fix the path to the plugins cache
[vlc] / extras / package / win32 / vlc.win32.nsi.in
index ae341f5042d96383315504f9a004966d68ddd52f..0c91243e4aafcafa225103cb384f92723e962282 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
@@ -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
 
@@ -308,7 +326,7 @@ FunctionEnd
 !macroend
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-; 3. Delete prefs and cache ;
+; 3. Delete prefs           ;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 !macro delprefs
@@ -328,6 +346,9 @@ FunctionEnd
     Goto "${Index}-Loop"
   "${Index}-End:"
   !undef Index
+  SetShellVarContext all
+  RMDir /r "$APPDATA\\VideoLAN"
+  SetShellVarContext current
 !macroend
 
 ;;;;;;;;;;;;;;;
@@ -411,6 +432,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
@@ -425,6 +447,7 @@ Section $Name_Section01 SEC01
 @BUILD_SKINS_TRUE@   !insertmacro InstallFolder skins
 @BUILD_HTTPD_TRUE@   !insertmacro InstallFolder http
 @BUILD_LUA_TRUE@     !insertmacro InstallFolder lua
+  ExecWait "$INSTDIR\vlc-cache-gen.exe $INSTDIR\plugins"
 
 
   ; URLs
@@ -440,7 +463,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
@@ -458,6 +481,11 @@ Section $Name_Section01 SEC01
   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
@@ -583,14 +611,14 @@ Section $Name_Section05 SEC05
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "Action" $Action_OnArrivalDVD
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeProgID" "VLC.DVDMovie"
-  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeVerb" "play"
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "InvokeVerb" "Open"
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayDVDMovieOnArrival" "Provider" "VideoLAN VLC media player"
 
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" "VLCPlayCDAudioOnArrival" ""
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "Action" $Action_OnArrivalAudioCD
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "DefaultIcon" '"$INSTDIR\vlc.exe",0'
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeProgID" "VLC.CDAudio"
-  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeVerb" "play"
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "InvokeVerb" "Open"
   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\VLCPlayCDAudioOnArrival" "Provider" "VideoLAN VLC media player"
   WriteRegStr HKCR "VLC.DVDMovie" "" "VLC DVD Movie"
   WriteRegStr HKCR "VLC.DVDMovie\shell" "" "Open"
@@ -643,6 +671,27 @@ 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"
@@ -713,6 +762,13 @@ Function .onInit
 
 FunctionEnd
 
+Function .OnInstFailed
+    UAC::Unload
+FunctionEnd
+
+Function .OnInstSuccess
+    UAC::Unload
+FunctionEnd
 ;; End function
 Section -Post
   WriteUninstaller "$INSTDIR\uninstall.exe"
@@ -869,6 +925,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 \
@@ -894,13 +951,38 @@ 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"