Date de création : 20/09/24
Date de Mise à Jour : 20/09/24
Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing $MsgBox = new-object -comobject wscript.shell $form = New-Object System.Windows.Forms.Form $form.Text = "Installation Galana" $form.Size = New-Object System.Drawing.Size(350,220) $form.StartPosition = "CenterScreen" $label_Title = New-Object System.Windows.Forms.Label $label_Title.Location = New-Object System.Drawing.Point(10,20) $label_Title.Size = New-Object System.Drawing.Size(280,20) $label_Title.AutoSize = $true $label_Title.Text = "Installation New Galana" $form.Controls.Add($label_Title) $label_ClientName = New-Object System.Windows.Forms.Label $label_ClientName.Location = New-Object System.Drawing.Point(10,50) $label_ClientName.Size = New-Object System.Drawing.Size(280,20) $label_ClientName.Text = "Nom Société " $form.Controls.Add($label_ClientName) $textBox_ClientName = New-Object System.Windows.Forms.TextBox $textBox_ClientName.Location = New-Object System.Drawing.Point(10,70) $textBox_ClientName.Size = New-Object System.Drawing.Size(260,20) $form.Controls.Add($textBox_ClientName) $CheckBox_InstallVirtualPrinter = New-Object System.Windows.Forms.CheckBox $CheckBox_InstallVirtualPrinter.Location = New-Object System.Drawing.Point(10,100) $CheckBox_InstallVirtualPrinter.width = 200 $CheckBox_InstallVirtualPrinter.Text = "Installation Virtual Printer" $CheckBox_InstallVirtualPrinter.Checked = $true $form.Controls.Add($CheckBox_InstallVirtualPrinter) $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Point(75,140) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = "OK" $OKButton.DialogResult = [System.Windows.Forms.DialogResult]::Ok $form.AcceptButton = $OKButton $form.Controls.Add($OKButton) $CancelButton = New-Object System.Windows.Forms.Button $CancelButton.Location = New-Object System.Drawing.Point(150,140) $CancelButton.Size = New-Object System.Drawing.Size(75,23) $CancelButton.Text = "Cancel" $CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel $form.CancelButton = $CancelButton $form.Controls.Add($CancelButton) $form.Add_Shown({ $form.Activate() }) $result = $form.ShowDialog() if ($result -eq [System.Windows.Forms.DialogResult]::OK) { $downloadUrl = "https://analys-informatique.com/TS2Log/TS2Log-GALANA.zip"; $downloadUrlForConnectFile = "https://analys-informatique.com/TS2Log/$($textBox_ClientName.Text)/Galana.connect.zip"; $downloadPath = "C:\Temp"; $downloadFile = "C:\Temp\TS2Log-GALANA.zip"; $ts2LogClientExePath = $downloadPath + "\TS2Log-Galana\Setup-ConnectionClient.exe"; $VirtualPrinterExePath = $downloadPath + "\TS2Log-Galana\Setup-VirtualPrinter-Client.exe"; if (! (Test-Path $downloadPath)) { New-Item -ItemType Directory -Path $downloadPath; } if (! (Test-Path $downloadFile)) { Invoke-WebRequest $downloadUrl -OutFile $downloadFile; } Expand-Archive $downloadFile -DestinationPath $downloadPath -Force; Start-Process -FilePath $ts2LogClientExePath -ArgumentList "/CURRENTUSER" -Wait; if ($CheckBox_InstallVirtualPrinter.Checked) { Start-Process -FilePath $VirtualPrinterExePath -ArgumentList "/CURRENTUSER" -Wait; } $documentPath = [environment]::GetFolderPath('MyDocuments'); $connexionPath = $documentPath + "\Mes Connexions"; $connexionFile = $connexionPath + "\Galana.connect"; if (! (Test-Path $connexionPath)) { New-Item -ItemType Directory -Path $connexionPath; } $downLoadConnectFileUrl = $downloadUrlForConnectFile.Replace("CustomerName", $($textBox_ClientName.Text)); try { Invoke-WebRequest $downLoadConnectFileUrl -OutFile $connexionFile; $icoFile = $downloadPath + "\TS2Log-Galana\Galana.ico" Copy-Item $icoFile -Destination $connexionPath $DesktopPath = [Environment]::GetFolderPath("Desktop"); $ShortcutTarget= $connexionFile; $ShortcutFile = $DesktopPath + "\GALANA.lnk"; $WScriptShell = New-Object -ComObject WScript.Shell; $Shortcut = $WScriptShell.CreateShortcut($ShortcutFile); $Shortcut.TargetPath = $ShortcutTarget; $Shortcut.IconLocation = $connexionPath + "\Galana.ico"; $Shortcut.Save(); Remove-Item $downloadFile; $pathToDelete = $downloadPath + "\TS2Log-Galana"; Remove-Item $pathToDelete -Force -Recurse; [System.Windows.Forms.MessageBox]::Show("L`'installation de $($textBox_ClientName.Text) au nouveau Galana s`'est acheve avec succes.", "Installation acheve avec succes",0, "None") } catch [System.Net.WebException] { $exceptionName = $_.toString() [System.Windows.Forms.MessageBox]::Show("[System.Net.WebException]`n`n$exceptionName`n`nLe nom du client $($textBox_ClientName.Text) n`est pas repertorie. Veuillez relancer le script d`'installation Galana." , "Erreur d'installation de Galana", 0, 16) } catch [System.Management.Automation.MethodException]{ $exceptionName = $_.ToString() [System.Windows.Forms.MessageBox]::Show("[System.Management.Automation.MethodException]`n`nnErreur survenu pendant l`'installation. Veuillez contacter Analys Informatique", "Erreur d'installation de Galana", 0, 16) } catch [System.Management.Automation.ParameterBindingException] { $exceptionName = $_.ToString() [System.Windows.Forms.MessageBox]::Show("[[System.Management.Automation.ParameterBindingException]]`n`n$exceptionName`n`nErreur survenu pendant l`'installation. Veuillez contacter Analys Informatique", "Erreur d'installation de Galana", 0, 16) } catch { $exceptionName = $_.Exception.GetType().ToString() [System.Windows.Forms.MessageBox]::Show("$exceptionName`n`nErreur non repertorie pendant l`'installation. Veuillez contacter Analys Informatique", "Erreur d'installation de Galana", 0, 16) } }
Si vous avez laisser cocher Installation Virtual printer , s'ensuit alors…
Une fois l'exécution du script terminée, fermez la fenêtre PowerShell
Si vous souhaitez imprimer instantanément depuis votre session Galana sur votre imprimante locale, installer l'outil Virtual printer. Pour cela :