Advertisement
yralexandre

VLC

Mar 23rd, 2015
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.39 KB | None | 0 0
  1. <#
  2. .SYNOPSIS
  3. This script performs the installation or uninstallation of an application(s).
  4. .DESCRIPTION
  5. The script is provided as a template to perform an install or uninstall of an application(s).
  6. The script either performs an "Install" deployment type or an "Uninstall" deployment type.
  7. The install deployment type is broken down into 3 main sections/phases: Pre-Install, Install, and Post-Install.
  8. The script dot-sources the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.
  9. .PARAMETER DeploymentType
  10. The type of deployment to perform. Default is: Install.
  11. .PARAMETER DeployMode
  12. Specifies whether the installation should be run in Interactive, Silent, or NonInteractive mode. Default is: Interactive. Options: Interactive = Shows dialogs, Silent = No dialogs, NonInteractive = Very silent, i.e. no blocking apps. NonInteractive mode is automatically set if it is detected that the process is not user interactive.
  13. .PARAMETER AllowRebootPassThru
  14. Allows the 3010 return code (requires restart) to be passed back to the parent process (e.g. SCCM) if detected from an installation. If 3010 is passed back to SCCM, a reboot prompt will be triggered.
  15. .PARAMETER TerminalServerMode
  16. Changes to "user install mode" and back to "user execute mode" for installing/uninstalling applications for Remote Destkop Session Hosts/Citrix servers.
  17. .EXAMPLE
  18. Deploy-Application.ps1
  19. .EXAMPLE
  20. Deploy-Application.ps1 -DeployMode 'Silent'
  21. .EXAMPLE
  22. Deploy-Application.ps1 -AllowRebootPassThru -AllowDefer
  23. .EXAMPLE
  24. Deploy-Application.ps1 -DeploymentType Uninstall
  25. .NOTES
  26. .LINK
  27. http://psappdeploytoolkit.codeplex.com
  28. #>
  29. [CmdletBinding()]
  30. Param (
  31. [Parameter(Mandatory=$false)]
  32. [ValidateSet('Install','Uninstall')]
  33. [string]$DeploymentType = 'Install',
  34. [Parameter(Mandatory=$false)]
  35. [ValidateSet('Yes','No')]
  36. [String] $CheckExist = 'No',
  37. [Parameter(Mandatory=$false)]
  38. [ValidateSet('Interactive','Silent','NonInteractive')]
  39. [string]$DeployMode = 'Interactive',
  40. [Parameter(Mandatory=$false)]
  41. [switch]$AllowRebootPassThru = $false,
  42. [Parameter(Mandatory=$false)]
  43. [switch]$TerminalServerMode = $false
  44. )
  45.  
  46. Try {
  47. ## Set the script execution policy for this process
  48. Try { Set-ExecutionPolicy -ExecutionPolicy 'ByPass' -Scope 'Process' -Force -ErrorAction 'Stop' } Catch {}
  49.  
  50. ##*===============================================
  51. ##* VARIABLE DECLARATION
  52. ##*===============================================
  53. ## Variables: Application
  54. [string]$appVendor = ''
  55. [string]$appName = 'VLC media player'
  56. [string]$DisplayName = 'VLC media player'
  57. [string]$appVersion = '2.2.0'
  58. [string]$DisplayVersion = '2.2.0'
  59. [string]$appArch = ''
  60. [string]$appLang = 'EN'
  61. [string]$appRevision = '01'
  62. [string]$appScriptVersion = '1.0.1503.20'
  63. [string]$appScriptDate = '2015.03.20'
  64. [string]$appScriptAuthor = 'alexayr'
  65.  
  66. ##*===============================================
  67.  
  68. ##* Do not modify section below
  69. #region DoNotModify
  70.  
  71. ## Variables: Exit Code
  72. [int32]$mainExitCode = 0
  73.  
  74. ## Variables: Script
  75. [string]$deployAppScriptFriendlyName = 'Deploy Application'
  76. [version]$deployAppScriptVersion = [version]'3.6.0'
  77. [string]$deployAppScriptDate = '03/11/2015'
  78. [hashtable]$deployAppScriptParameters = $psBoundParameters
  79.  
  80. ## Variables: Environment
  81. [string]$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
  82.  
  83. ## Dot source the required App Deploy Toolkit Functions
  84. Try {
  85. [string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
  86. If (-not (Test-Path -Path $moduleAppDeployToolkitMain -PathType Leaf)) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
  87. . $moduleAppDeployToolkitMain
  88. }
  89. Catch {
  90. [int32]$mainExitCode = 1
  91. Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: `n$($_.Exception.Message)`n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
  92. Exit $mainExitCode
  93. }
  94.  
  95. #endregion
  96. ##* Do not modify section above
  97. ##*===============================================
  98. ##* END VARIABLE DECLARATION
  99. ##*===============================================
  100.  
  101. If ($deploymentType -ine 'Uninstall') {
  102. ##*===============================================
  103. ##* PRE-INSTALLATION
  104. ##*===============================================
  105. [string]$installPhase = 'Pre-Installation'
  106.  
  107. $InstallName = Get-InstalledApplication -Name "VLC media player"
  108. $InstallVersion = (Get-InstalledApplication -Name "VLC media player").DisplayVersion
  109. if ($CheckExist -ieq 'Yes') {Check-Exist}
  110. ## Show Welcome Message, close Internet Explorer if required, allow up to 3 deferrals, verify there is enough disk space to complete the install, and persist the prompt
  111. Show-InstallationWelcome -CloseApps 'vlc' -AllowDefer -DeferTimes 5 -CheckDiskSpace -PersistPrompt
  112.  
  113. ## Show Progress Message (with the default message)
  114. Show-InstallationProgress
  115.  
  116. ## <Perform Pre-Installation tasks here>
  117.  
  118.  
  119. ##*===============================================
  120. ##* INSTALLATION
  121. ##*===============================================
  122. [string]$installPhase = 'Installation'
  123.  
  124. ## <Perform Installation tasks here>
  125. if ($is64Bit -eq $true) {
  126. if ((Test-Path "$envProgramFiles\VideoLAN\VLC\uninstall.exe") -eq $true ) { Execute-Process -FilePath "$envProgramFiles\VideoLAN\VLC\uninstall.exe" -Arguments "/S" -WindowStyle Hidden -IgnoreExitCodes "1,2,3" }
  127. if ((Test-Path "$envProgramFilesX86\VideoLAN\VLC\uninstall.exe") -eq $true ) { Execute-Process -FilePath "$envProgramFilesX86\VideoLAN\VLC\uninstall.exe" -Arguments "/S" -WindowStyle Hidden -IgnoreExitCodes "1,2,3" }
  128. Execute-Process -FilePath "vlc-2.2.0-win64.exe" -Arguments "/S /desktopicon=no /quicklaunchicon=no" -WindowStyle Hidden -IgnoreExitCodes "1,2,3"
  129. if ((Test-Path "$envAppData\vlc") -eq $false ) { New-Folder -Path "$envAppData\vlc" }
  130. if ((Test-Path "$envAppData\vlc") -eq $true ) { Copy-File -Path "$dirSupportFiles\vlcrc" -Destination "$envAppData\vlc\vlcrc" -Recurse }
  131. Set-RegistryKey -Key 'HKEY_CLASSES_ROOT\DVD\shell\play\command' -Value "$envCommonProgramFilesX86\VideoLAN\VLC\vlc.exe --started-from-file dvd://%1" -Type String
  132. if ((Test-Path "$envPublic\Desktop\VLC Media Player.lnk") -eq $true ) { Remove-File -Path "$envPublic\Desktop\VLC Media Player.lnk" -Recurse }
  133. Refresh-Desktop
  134.  
  135. } Else {
  136. if ((Test-Path "$envProgramFilesX86\VideoLAN\VLC\uninstall.exe") -eq $true ) { Execute-Process -FilePath "$envProgramFilesX86\VideoLAN\VLC\uninstall.exe" -Arguments "/S" -WindowStyle Hidden -IgnoreExitCodes "1,2,3" }
  137. Execute-Process -FilePath "vlc-2.2.0-win32.exe" -Arguments "/S /desktopicon=no /quicklaunchicon=no" -WindowStyle Hidden -IgnoreExitCodes "1,2,3"
  138. if ((Test-Path "$envAppData\vlc") -eq $false ) { New-Folder -Path "$envAppData\vlc" }
  139. if ((Test-Path "$envAppData\vlc") -eq $true ) { Copy-File -Path "$dirSupportFiles\vlcrc" -Destination "$envAppData\vlc\vlcrc" -Recurse }
  140. Set-RegistryKey -Key 'HKEY_CLASSES_ROOT\DVD\shell\play\command' -Value "$envCommonProgramFilesX86\VideoLAN\VLC\vlc.exe --started-from-file dvd://%1" -Type String
  141. if ((Test-Path "$envPublic\Desktop\VLC Media Player.lnk") -eq $true ) { Remove-File -Path "$envPublic\Desktop\VLC Media Player.lnk" -Recurse }
  142. Refresh-Desktop
  143.  
  144. }
  145.  
  146.  
  147. ##*===============================================
  148. ##* POST-INSTALLATION
  149. ##*===============================================
  150. [string]$installPhase = 'Post-Installation'
  151.  
  152. ## <Perform Post-Installation tasks here>
  153.  
  154. ## Display a message at the end of the install
  155. #Show-InstallationPrompt -Message "The installation of $DisplayName $DisplayVersion complete." -ButtonMiddleText 'OK' -Icon Information -NoWait
  156. $InstallName = Get-InstalledApplication -Name "VLC media player"
  157. $InstallVersion = (Get-InstalledApplication -Name "VLC media player").DisplayVersion
  158. StatusInstall
  159. }
  160. ElseIf ($deploymentType -ieq 'Uninstall')
  161. {
  162. ##*===============================================
  163. ##* PRE-UNINSTALLATION
  164. ##*===============================================
  165. [string]$installPhase = 'Pre-Uninstallation'
  166.  
  167. $InstallName = Get-InstalledApplication -Name "VLC media player"
  168. $InstallVersion = (Get-InstalledApplication -Name "VLC media player").DisplayVersion
  169. if ($CheckExist -ieq 'Yes') {Check-Exist}
  170. # Show Welcome Message, close Internet Explorer if required with a 60 second countdown before automatically closing
  171. Show-InstallationWelcome -CloseApps 'vlc' -CloseAppsCountdown 60
  172.  
  173. ## Show Progress Message (with the default message)
  174. Show-InstallationProgress
  175.  
  176. ## <Perform Pre-Uninstallation tasks here>
  177.  
  178.  
  179. ##*===============================================
  180. ##* UNINSTALLATION
  181. ##*===============================================
  182. [string]$installPhase = 'Uninstallation'
  183.  
  184. # <Perform Uninstallation tasks here>
  185. if ($is64Bit -eq $true) {
  186. if ((Test-Path "$envProgramFiles\VideoLAN\VLC\uninstall.exe") -eq $true ) { Execute-Process -FilePath "$envProgramFiles\VideoLAN\VLC\uninstall.exe" -Arguments "/S" -WindowStyle Hidden -IgnoreExitCodes "1,2,3" }
  187. if ((Test-Path "$envProgramFilesX86\VideoLAN\VLC\uninstall.exe") -eq $true ) { Execute-Process -FilePath "$envProgramFilesX86\VideoLAN\VLC\uninstall.exe" -Arguments "/S" -WindowStyle Hidden -IgnoreExitCodes "1,2,3" }
  188. Remove-Folder -Path "$envCommonProgramFilesX86\VideoLAN\VLC"
  189. Remove-Folder -Path "$envAppData\vlc"
  190. if ((Test-Path "$envPublic\Desktop\VLC Media Player.lnk") -eq $true ) { Remove-File -Path "$envPublic\Desktop\VLC Media Player.lnk" -Recurse }
  191. Remove-Folder -Path "$envProgramFiles\VideoLAN"
  192. Remove-Folder -Path "$envProgramFilesX86\VideoLAN"
  193. Refresh-Desktop
  194. } Else {
  195. if ((Test-Path "$envProgramFilesX86\VideoLAN\VLC\uninstall.exe") -eq $true ) { Execute-Process -FilePath "$envProgramFilesX86\VideoLAN\VLC\uninstall.exe" -Arguments "/S" -WindowStyle Hidden -IgnoreExitCodes "1,2,3" }
  196. Remove-Folder -Path "$envCommonProgramFilesX86\VideoLAN\VLC"
  197. Remove-Folder -Path "$envAppData\vlc"
  198. if ((Test-Path "$envPublic\Desktop\VLC Media Player.lnk") -eq $true ) { Remove-File -Path "$envPublic\Desktop\VLC Media Player.lnk" -Recurse }
  199. Remove-Folder -Path "$envProgramFilesX86\VideoLAN"
  200. Refresh-Desktop
  201. }
  202.  
  203. #Display a message at the end of the uninstall
  204. #Show-InstallationPrompt -Message "The uninstallation of $DisplayName $DisplayVersion complete." -ButtonMiddleText 'OK' -Icon Information -NoWait
  205. $InstallName = Get-InstalledApplication -Name "VLC media player"
  206. $InstallVersion = (Get-InstalledApplication -Name "VLC media player").DisplayVersion
  207. StatusUninstall
  208.  
  209. ##*===============================================
  210. ##* POST-UNINSTALLATION
  211. ##*===============================================
  212. [string]$installPhase = 'Post-Uninstallation'
  213.  
  214. ## <Perform Post-Uninstallation tasks here>
  215. }
  216.  
  217. ##*===============================================
  218. ##* END SCRIPT BODY
  219. ##*===============================================
  220.  
  221. ## Call the Exit-Script function to perform final cleanup operations
  222. Exit-Script -ExitCode $mainExitCode
  223. }
  224. Catch {
  225. [int32]$mainExitCode = 60001
  226. [string]$mainErrorMessage = "$(Resolve-Error)"
  227. Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
  228. Show-DialogBox -Text $mainErrorMessage -Icon 'Stop'
  229. Exit-Script -ExitCode $mainExitCode
  230. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement