Advertisement
Thunder-Menu

Last_Flash_AxShockwaveFlashObjects_ActiveX_Version10.1.ps1

Apr 13th, 2023
1,128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 3.64 KB | Source Code | 0 0
  1. Add-Type -AssemblyName System.Windows.Forms
  2. Add-Type -AssemblyName System.Drawing
  3.  
  4. $url = "https://archive.org/download/adobeflash-10_1/Flash_10_1_Setup.exe"
  5. $output = "$env:TEMP\Flash_10_1_Setup.exe"
  6. $extractPath = "$env:TEMP"
  7.  
  8. # Vérifier si Flash est déjà installé
  9. if (Test-Path "HKLM:\SOFTWARE\Macromedia\FlashPlayerActiveX") {
  10.     Write-Host "Flash est déjà installé sur cet ordinateur."
  11.     Exit
  12. }
  13.  
  14. # Vérifier si le fichier d'installation existe déjà
  15. if (Test-Path "$extractPath\Flash_10_1_Setup.exe") {
  16.     Write-Host "Le fichier d'installation existe déjà. Démarrage de l'installation..."
  17.     Start-Process -FilePath "$extractPath\Flash_10_1_Setup.exe" -Wait -PassThru -WindowStyle Normal -Verb RunAs
  18.     Exit
  19. }
  20.  
  21. # Télécharger le programme d'installation de Flash
  22. $client = New-Object System.Net.WebClient
  23.  
  24. $form = New-Object System.Windows.Forms.Form
  25. $form.Text = "Installation de Flash Player"
  26. $form.Width = 400
  27. $form.Height = 100
  28. $form.FormBorderStyle = "FixedDialog"
  29. $form.MaximizeBox = $false
  30. $form.StartPosition = "CenterScreen"
  31.  
  32. $label = New-Object System.Windows.Forms.Label
  33. $label.Text = "Téléchargement en cours..."
  34. $label.AutoSize = $true
  35. $label.Location = New-Object System.Drawing.Point(10, 10)
  36.  
  37. $progressBar = New-Object System.Windows.Forms.ProgressBar
  38. $progressBar.Minimum = 0
  39. $progressBar.Maximum = 100
  40. $progressBar.Value = 0
  41. $progressBar.Width = 300
  42. $progressBar.Location = New-Object System.Drawing.Point(10, 30)
  43.  
  44. $form.Controls.Add($label)
  45. $form.Controls.Add($progressBar)
  46.  
  47. $client.add_DownloadProgressChanged({
  48.     $progressBar.Value = [int](($args.BytesReceived / $args.TotalBytesToReceive) * 100)
  49. })
  50.  
  51. $client.DownloadFileAsync($url, $output)
  52.  
  53. # Gérer les événements de progression de téléchargement
  54. $client.add_DownloadFileCompleted({
  55.     if ($args.Error) {
  56.         Write-Host "Une erreur s'est produite lors du téléchargement : $($args.Error.Message)"
  57.         Exit
  58.     }
  59.  
  60. # Attendre la fin de l'extraction
  61. while ($progressBar.Value -ne $progressBar.Maximum) {
  62.     Start-Sleep -Milliseconds 100
  63.     $progressBar.Value++
  64. }
  65.  
  66. # Vérifier si le fichier .exe existe
  67. if (Test-Path "$extractPath\Flash_10_1_Setup.exe") {
  68.     # Vérifier si la taille du fichier .exe est égale à 0
  69.     if ((Get-Item "$extractPath\Flash_10_1_Setup.exe").Length -eq 0) {
  70.         # Attendre que le fichier ne soit plus protégé en écriture
  71.         do {
  72.             Start-Sleep -Milliseconds 100
  73.         } while ((Get-Item "$extractPath\Flash_10_1_Setup.exe").IsReadOnly)
  74.  
  75.         # Lancer le processus d'installation
  76.         $installProcess = Start-Process -FilePath "$extractPath\Flash_10_1_Setup.exe" -Wait -PassThru -WindowStyle Normal -Verb RunAs
  77.         # Vérifier si l'installation s'est bien déroulée
  78.         if ($installProcess.ExitCode -eq 0) {
  79.             Write-Host "Installation terminée avec succès."
  80.         }
  81.         else {
  82.             Write-Host "Une erreur s'est produite lors de l'installation."
  83.         }
  84.     }
  85.     else {
  86.         # Lancer le processus d'installation
  87.         $installProcess = Start-Process -FilePath "$extractPath\Flash_10_1_Setup.exe" -Wait -PassThru -WindowStyle Normal -Verb RunAs
  88.         # Vérifier si l'installation s'est bien déroulée
  89.         if ($installProcess.ExitCode -eq 0) {
  90.             Write-Host "Installation terminée avec succès."
  91.         }
  92.         else {
  93.             Write-Host "Une erreur s'est produite lors de l'installation."
  94.         }
  95.     }
  96. }
  97. else {
  98.     Write-Host "Le fichier Flash_10_1_Setup.exe est introuvable."
  99. }
  100.  
  101.  
  102.     # Fermer la fenêtre
  103.     $form.Close()
  104. })
  105.  
  106. # Afficher la fenêtre
  107. $form.ShowDialog() | Out-Null
  108. pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement