Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-Type -AssemblyName System.Windows.Forms
- Add-Type -AssemblyName System.Drawing
- Add-Type -AssemblyName System.IO.Compression.FileSystem
- $url = "https://archive.org/download/AdobeFlashPlayer32.0.0.465/install_flash_player.zip"
- $output = "$env:TEMP\install_flash_player.zip"
- $extractPath = "$env:TEMP\FlashInstaller"
- # Vérifier si Flash est déjà installé
- if (Test-Path "HKLM:\SOFTWARE\Macromedia\FlashPlayerActiveX") {
- Write-Host "Flash est déjà installé sur cet ordinateur."
- Exit
- }
- # Vérifier si le fichier d'installation existe déjà
- if (Test-Path "$extractPath\install_flash_player.exe") {
- Write-Host "Le fichier d'installation existe déjà. Démarrage de l'installation..."
- Start-Process -FilePath "$extractPath\install_flash_player.exe" -Wait -PassThru -WindowStyle Normal -Verb RunAs
- Exit
- }
- # Télécharger le programme d'installation de Flash
- $client = New-Object System.Net.WebClient
- $form = New-Object System.Windows.Forms.Form
- $form.Text = "Installation de Flash Player"
- $form.Width = 400
- $form.Height = 100
- $form.FormBorderStyle = "FixedDialog"
- $form.MaximizeBox = $false
- $form.StartPosition = "CenterScreen"
- $label = New-Object System.Windows.Forms.Label
- $label.Text = "Téléchargement en cours..."
- $label.AutoSize = $true
- $label.Location = New-Object System.Drawing.Point(10, 10)
- $progressBar = New-Object System.Windows.Forms.ProgressBar
- $progressBar.Minimum = 0
- $progressBar.Maximum = 100
- $progressBar.Value = 0
- $progressBar.Width = 300
- $progressBar.Location = New-Object System.Drawing.Point(10, 30)
- $form.Controls.Add($label)
- $form.Controls.Add($progressBar)
- $client.add_DownloadProgressChanged({
- $progressBar.Value = [int](($args.BytesReceived / $args.TotalBytesToReceive) * 100)
- })
- $client.DownloadFileAsync($url, $output)
- # Gérer les événements de progression de téléchargement
- $client.add_DownloadFileCompleted({
- if ($args.Error) {
- Write-Host "Une erreur s'est produite lors du téléchargement : $($args.Error.Message)"
- Exit
- }
- # Extraire les fichiers
- Write-Host "Extraction des fichiers..."
- $progressBar.Value = 0
- $progressBar.Maximum = 100
- [System.IO.Compression.ZipFile]::ExtractToDirectory($output, $extractPath) | Out-Null
- # Attendre la fin de l'extraction
- while ($progressBar.Value -ne $progressBar.Maximum) {
- Start-Sleep -Milliseconds 100
- $progressBar.Value++
- }
- # Vérifier si le fichier .exe existe
- if (Test-Path "$extractPath\install_flash_player.exe") {
- # Vérifier si la taille du fichier .exe est égale à 0
- if ((Get-Item "$extractPath\install_flash_player.exe").Length -eq 0) {
- # Attendre que le fichier ne soit plus protégé en écriture
- do {
- Start-Sleep -Milliseconds 100
- } while ((Get-Item "$extractPath\install_flash_player.exe").IsReadOnly)
- # Lancer le processus d'installation
- $installProcess = Start-Process -FilePath "$extractPath\install_flash_player.exe" -Wait -PassThru -WindowStyle Normal -Verb RunAs
- # Vérifier si l'installation s'est bien déroulée
- if ($installProcess.ExitCode -eq 0) {
- Write-Host "Installation terminée avec succès."
- }
- else {
- Write-Host "Une erreur s'est produite lors de l'installation."
- }
- }
- else {
- # Lancer le processus d'installation
- $installProcess = Start-Process -FilePath "$extractPath\install_flash_player.exe" -Wait -PassThru -WindowStyle Normal -Verb RunAs
- # Vérifier si l'installation s'est bien déroulée
- if ($installProcess.ExitCode -eq 0) {
- Write-Host "Installation terminée avec succès."
- }
- else {
- Write-Host "Une erreur s'est produite lors de l'installation."
- }
- }
- }
- else {
- Write-Host "Le fichier install_flash_player.exe est introuvable."
- }
- # Fermer la fenêtre
- $form.Close()
- })
- # Afficher la fenêtre
- $form.ShowDialog() | Out-Null
- pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement