ARD 1 -->
Download driver Ricoh
Click to download the driver
⬇ Download driver
Download font
Download barcode font
⬇ Download font
Sillage + Explor + LIMS
Show & copy installer script
📋 Show SILLAGE Script
🔒 Accès Sécurisé
Mot de passe requis
🚪 Accéder
Google Sheet – Script
Click to show the full script
📋 Show Google Sheet Script
PowerShell — SILLAGE Installer
✕
# launcher_sillage_barcode.ps1 # Installation Client SILLAGE + Police "3 of 9 Barcode" depuis ZIP (dafont) Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing # --- Vérifier droits admin --- if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator)) { $arg = "-NoProfile -ExecutionPolicy Bypass -File `"" + $PSCommandPath + "`"" Start-Process powershell -ArgumentList $arg -Verb RunAs exit } # --- CONFIG par défaut (sera modifié selon sélection) --- $DesktopPath = "C:\Users\formation1\Desktop" # valeur par défaut (Hôpital) $SillageBaseDir = "C:\sillage" $SillageZipUrl = "http://SIB-CHUR-APP1:52000/clientInstallation/sillage.zip" $ProdDir = "C:\sillage\SIB-CHUR-APP1_52000" $FormDir = "C:\sillage\CHU-APP-SIB2_52000" $TestDir = "C:\sillage\CHU-APP-SIB1_52000" $ProdUrl = "http://SIB-CHUR-APP1:52000/sillagePSDM" $FormUrl = "http://chu-app-sib2:52000/sillagePSDM" $TestUrl = "http://chu-app-sib1:52000/sillagePSDM" $ProdIcon = Join-Path $ProdDir "sillage.ico" $XplorUrl = "http://10.248.14.50/XAEXPLOIT/" $LimsUrl = "http://10.0.243.38/LISCM6/" # Google Sheet $GoogleAppsScriptURL = "https://script.google.com/macros/s/AKfycbyemFeU6K7BmzLzNwoNCGRMwde6Fs6cKwJLyo_AZ2ZwIAGuVt-oEy24Cf9ve8SY7abOkA/exec" $GoogleSecret = "MySecureKey123" # Police Barcode ZIP $BarcodeFontName = "3 of 9 Barcode" $BarcodeZipUrl = "https://dl.dafont.com/dl/?f=3of9_barcode" # --- Fonctions utilitaires --- function Write-Log($t){ Write-Host "[INFO] $t" } function Install-BarcodeFont(){ try { $fontsPath = "C:\Windows\Fonts" $fontsRegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" $zipFile = Join-Path $env:TEMP "3of9_barcode.zip" $extractDir = Join-Path $env:TEMP "font_3of9" # vérifier si déjà installé $existing = Get-ChildItem $fontsPath -Filter "*3of9*.ttf" -ErrorAction SilentlyContinue if ($existing) { Write-Log "Police déjà installée : $($existing.Name)" return } Write-Log "Téléchargement de la police ZIP..." try { (New-Object System.Net.WebClient).DownloadFile($BarcodeZipUrl, $zipFile) } catch { Write-Log "Impossible de télécharger la police depuis $BarcodeZipUrl : $($_.Exception.Message)" return } if (Test-Path $extractDir) { Remove-Item -Recurse -Force $extractDir } Expand-Archive -Path $zipFile -DestinationPath $extractDir -Force Remove-Item $zipFile -Force # chercher .ttf à l’intérieur $ttf = Get-ChildItem -Path $extractDir -Filter "*.ttf" -Recurse | Select-Object -First 1 if (-not $ttf) { Write-Host "❌ Aucun fichier .ttf trouvé dans l’archive." return } $destFont = Join-Path $fontsPath $ttf.Name Copy-Item $ttf.FullName -Destination $destFont -Force New-ItemProperty -Path $fontsRegPath -Name "$BarcodeFontName (TrueType)" -Value $ttf.Name -PropertyType String -Force | Out-Null Remove-Item $extractDir -Recurse -Force Write-Log "✅ Police '$BarcodeFontName' installée : $($ttf.Name)" } catch { Write-Host "❌ Erreur installation police : $($_.Exception.Message)" } } function Download-File($url,$dest){ try { (New-Object System.Net.WebClient).DownloadFile($url,$dest); return $true } catch { return $false } } function Install-Sillage($url,$destDir){ try { if (-not (Test-Path $SillageBaseDir)){New-Item -ItemType Directory -Path $SillageBaseDir -Force|Out-Null} $tmp = Join-Path $env:TEMP "sillage.zip" if (-not (Download-File $url $tmp)) { Write-Log "❌ Échec téléchargement Sillage depuis $url" return $false } if (Test-Path $destDir){Remove-Item -Recurse -Force $destDir} Expand-Archive -Path $tmp -DestinationPath $destDir -Force Remove-Item $tmp -Force return $true }catch{ Write-Log "Erreur Install-Sillage: $($_.Exception.Message)" return $false } } function Ensure-Directory($path){ try { $dir = Split-Path $path -Parent if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Path $dir -Force | Out-Null } } catch { } } function Create-SillageShortcut($desktop,$name,$exe,$url,$icon=""){ try { if (-not (Test-Path $desktop)) { Ensure-Directory (Join-Path $desktop "dummy.txt"); New-Item -ItemType Directory -Path $desktop -Force | Out-Null } $lnk = Join-Path $desktop "$name.lnk" $wsh = New-Object -ComObject WScript.Shell $sc = $wsh.CreateShortcut($lnk) $sc.TargetPath = $exe $sc.Arguments = $url $sc.WorkingDirectory = Split-Path $exe -Parent if ($icon -and (Test-Path $icon)) { $sc.IconLocation = $icon } $sc.Save() Write-Log "Raccourci créé: $lnk" } catch { Write-Log "Erreur création raccourci $name : $($_.Exception.Message)" } } function Create-UrlShortcut($desktop,$name,$url){ try { if (-not (Test-Path $desktop)) { Ensure-Directory (Join-Path $desktop "dummy.txt"); New-Item -ItemType Directory -Path $desktop -Force | Out-Null } $path = Join-Path $desktop "$name.url" "[InternetShortcut]`nURL=$url`n" | Out-File -FilePath $path -Encoding ASCII Write-Log "Raccourci URL créé: $path" } catch { Write-Log "Erreur création URL $name : $($_.Exception.Message)" } } function Send-ToGoogleSheet($secret,$location,$tag){ try { $serial = (Get-CimInstance Win32_BIOS).SerialNumber $computer = $env:COMPUTERNAME $timestamp = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss") $payload = @{ Secret = $secret Location = $location Tag = $tag Computer = $computer Serial = $serial Timestamp = $timestamp } | ConvertTo-Json Invoke-RestMethod -Uri $GoogleAppsScriptURL -Method Post -Body $payload -ContentType "application/json" -ErrorAction Stop [System.Windows.Forms.MessageBox]::Show("✅ Données envoyées avec succès !`nTAG : $tag","Google Sheet",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Information) } catch { [System.Windows.Forms.MessageBox]::Show("❌ Erreur d’envoi : $($_.Exception.Message)","Erreur",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Error) } } # ═══════════════════════════════════════════════════════════════════ # Script Complet - Téléchargement et Application Wallpaper/Lock Screen # ═══════════════════════════════════════════════════════════════════ # URLs des images $Wallpaper = "https://youssefsmain.me/h.jpeg" $LockWallpaper = "https://youssefsmain.me/f.jpg" # Dossier de destination $WallpaperDir = "C:\Wallpapers" $WallpaperPath = "$WallpaperDir\Desktop_Wallpaper.jpg" $LockWallpaperPath = "$WallpaperDir\Lock_Screen.jpg" # ═══════════════════════════════════════════════════════════════════ # ÉTAPE 1: Créer le dossier si nécessaire # ═══════════════════════════════════════════════════════════════════ Write-Host "═══════════════════════════════════════════════════" -ForegroundColor Cyan Write-Host "🚀 Démarrage du script..." -ForegroundColor Green Write-Host "═══════════════════════════════════════════════════" -ForegroundColor Cyan Write-Host "" if (-not (Test-Path -Path $WallpaperDir)) { Write-Host "📁 Création du dossier: $WallpaperDir" -ForegroundColor Yellow New-Item -Path $WallpaperDir -ItemType Directory -Force | Out-Null Write-Host "✅ Dossier créé avec succès" -ForegroundColor Green } else { Write-Host "✅ Dossier déjà existant: $WallpaperDir" -ForegroundColor Green } Write-Host "" # ═══════════════════════════════════════════════════════════════════ # ÉTAPE 2: Télécharger les images # ═══════════════════════════════════════════════════════════════════ Write-Host "📥 Téléchargement des images..." -ForegroundColor Cyan Write-Host "───────────────────────────────────────────────────" -ForegroundColor DarkGray try { # Télécharger Desktop Wallpaper Write-Host "🖼️ Téléchargement: Desktop Wallpaper..." -ForegroundColor Yellow $webClient = New-Object System.Net.WebClient $webClient.DownloadFile($Wallpaper, $WallpaperPath) Write-Host " ✅ Desktop Wallpaper téléchargé → $WallpaperPath" -ForegroundColor Green # Télécharger Lock Screen Write-Host "🔒 Téléchargement: Lock Screen..." -ForegroundColor Yellow $webClient.DownloadFile($LockWallpaper, $LockWallpaperPath) Write-Host " ✅ Lock Screen téléchargé → $LockWallpaperPath" -ForegroundColor Green $webClient.Dispose() } catch { Write-Host "❌ ERREUR lors du téléchargement: $_" -ForegroundColor Red exit 1 } Write-Host "" # ═══════════════════════════════════════════════════════════════════ # ÉTAPE 3: Appliquer le Desktop Wallpaper # ═══════════════════════════════════════════════════════════════════ Write-Host "🎨 Application du Desktop Wallpaper..." -ForegroundColor Cyan Write-Host "───────────────────────────────────────────────────" -ForegroundColor DarkGray # Méthode 1: SystemParametersInfo (API Windows) Add-Type @" using System; using System.Runtime.InteropServices; public class Wallpaper { [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni); } "@ $SPI_SETDESKWALLPAPER = 0x0014 $SPIF_UPDATEINIFILE = 0x01 $SPIF_SENDCHANGE = 0x02 try { [Wallpaper]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $WallpaperPath, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE) | Out-Null Write-Host "✅ Desktop Wallpaper appliqué (SystemParametersInfo)" -ForegroundColor Green } catch { Write-Host "⚠️ Méthode SystemParametersInfo a échoué" -ForegroundColor Yellow } # Méthode 2: Registry (pour assurer la persistance) try { Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name Wallpaper -Value $WallpaperPath -Force Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name WallpaperStyle -Value "10" -Force # Fill Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name TileWallpaper -Value "0" -Force Write-Host "✅ Registre mis à jour pour persistance" -ForegroundColor Green } catch { Write-Host "⚠️ Mise à jour du registre a échoué" -ForegroundColor Yellow } Write-Host "" # ═══════════════════════════════════════════════════════════════════ # ÉTAPE 4: Appliquer le Lock Screen # ═══════════════════════════════════════════════════════════════════ Write-Host "🔐 Application du Lock Screen..." -ForegroundColor Cyan Write-Host "───────────────────────────────────────────────────" -ForegroundColor DarkGray try { # Créer la clé si elle n'existe pas $PersonalizationPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" if (-not (Test-Path $PersonalizationPath)) { New-Item -Path $PersonalizationPath -Force | Out-Null Write-Host "📝 Clé de registre créée: Personalization" -ForegroundColor Yellow } # Appliquer le Lock Screen Set-ItemProperty -Path $PersonalizationPath -Name LockScreenImage -Value $LockWallpaperPath -Force Set-ItemProperty -Path $PersonalizationPath -Name PersonalColors_Background -Value "#000000" -Force Write-Host "✅ Lock Screen configuré dans le registre" -ForegroundColor Green } catch { Write-Host "❌ ERREUR lors de la configuration du Lock Screen: $_" -ForegroundColor Red Write-Host "⚠️ Assurez-vous d'exécuter en tant qu'Administrateur" -ForegroundColor Yellow } Write-Host "" # ═══════════════════════════════════════════════════════════════════ # ÉTAPE 5: Rafraîchir l'affichage # ═══════════════════════════════════════════════════════════════════ Write-Host "🔄 Rafraîchissement de l'affichage..." -ForegroundColor Cyan Write-Host "───────────────────────────────────────────────────" -ForegroundColor DarkGray try { # Forcer le rafraîchissement rundll32.exe user32.dll, UpdatePerUserSystemParameters, 1, True Write-Host "✅ Affichage rafraîchi" -ForegroundColor Green } catch { Write-Host "⚠️ Rafraîchissement manuel peut être nécessaire" -ForegroundColor Yellow } Write-Host "" # ═══════════════════════════════════════════════════════════════════ # RÉSUMÉ FINAL # ═══════════════════════════════════════════════════════════════════ Write-Host "═══════════════════════════════════════════════════" -ForegroundColor Cyan Write-Host "✨ SCRIPT TERMINÉ AVEC SUCCÈS!" -ForegroundColor Green Write-Host "═══════════════════════════════════════════════════" -ForegroundColor Cyan Write-Host "" Write-Host "📊 Résumé:" -ForegroundColor White Write-Host " 🖼️ Desktop Wallpaper: $WallpaperPath" -ForegroundColor White Write-Host " 🔒 Lock Screen: $LockWallpaperPath" -ForegroundColor White Write-Host "" Write-Host "💡 Notes:" -ForegroundColor Yellow Write-Host " • Si le Lock Screen ne s'applique pas immédiatement," -ForegroundColor Gray Write-Host " exécutez le script en tant qu'Administrateur" -ForegroundColor Gray Write-Host " • Redémarrez l'ordinateur si nécessaire pour voir" -ForegroundColor Gray Write-Host " le Lock Screen" -ForegroundColor Gray Write-Host "" Write-Host "═══════════════════════════════════════════════════" -ForegroundColor Cyan # --- UI --- $form = New-Object System.Windows.Forms.Form $form.Text = "🚀 Installation Client SILLAGE + Police Barcode" $form.Size = New-Object System.Drawing.Size(560,560) $form.StartPosition = "CenterScreen" $form.BackColor = [System.Drawing.ColorTranslator]::FromHtml("#f9fafb") $form.FormBorderStyle = "FixedDialog" $panel = New-Object System.Windows.Forms.Panel $panel.Size = "520,500" $panel.Location = "10,10" $panel.BackColor = [System.Drawing.ColorTranslator]::FromHtml("#ffffff") $panel.BorderStyle = "FixedSingle" $form.Controls.Add($panel) $title = New-Object System.Windows.Forms.Label $title.Text = "🧩 Installation du client SILLAGE" $title.Font = New-Object System.Drawing.Font("Segoe UI",14,[System.Drawing.FontStyle]::Bold) $title.Location = "20,15" $title.AutoSize = $true $panel.Controls.Add($title) $lblType = New-Object System.Windows.Forms.Label $lblType.Text = "Type d'emplacement :" $lblType.Location = "20,55" $panel.Controls.Add($lblType) $cbType = New-Object System.Windows.Forms.ComboBox $cbType.Location = "20,75" $cbType.Size = "240,25" $cbType.Items.AddRange(@("Hôpital","Université","PC hors domaine")) $cbType.SelectedIndex = 0 $panel.Controls.Add($cbType) $lblDesktopInfo = New-Object System.Windows.Forms.Label $lblDesktopInfo.Text = "Les raccourcis seront créés sur le bureau correspondant au type sélectionné." $lblDesktopInfo.Location = "280,75" $lblDesktopInfo.Size = "220,40" $lblDesktopInfo.AutoSize = $false $panel.Controls.Add($lblDesktopInfo) $lblLoc = New-Object System.Windows.Forms.Label $lblLoc.Text = "Emplacement (libellé):" $lblLoc.Location = "20,110" $panel.Controls.Add($lblLoc) $txtLoc = New-Object System.Windows.Forms.TextBox $txtLoc.Location = "20,130";$txtLoc.Size = "450,25" $panel.Controls.Add($txtLoc) $lblTag = New-Object System.Windows.Forms.Label $lblTag.Text = "TAG (préserver les zéros):" $lblTag.Location = "20,165" $panel.Controls.Add($lblTag) $txtTag = New-Object System.Windows.Forms.TextBox $txtTag.Location = "20,185";$txtTag.Size = "200,25" $panel.Controls.Add($txtTag) # Checkboxes $chkTest = New-Object System.Windows.Forms.CheckBox $chkTest.Text="Installer SILLAGE TEST";$chkTest.Location="20,220";$chkTest.Checked=$true $chkForm = New-Object System.Windows.Forms.CheckBox $chkForm.Text="Installer SILLAGE FORMATION";$chkForm.Location="20,245";$chkForm.Checked=$true $chkProd = New-Object System.Windows.Forms.CheckBox $chkProd.Text="Installer SILLAGE PRODUCTION";$chkProd.Location="20,270";$chkProd.Checked=$true $chkXplor = New-Object System.Windows.Forms.CheckBox $chkXplor.Text="Créer raccourci XPLORE";$chkXplor.Location="20,295";$chkXplor.Checked=$true $chkLims = New-Object System.Windows.Forms.CheckBox $chkLims.Text="Créer raccourci LIMS";$chkLims.Location="20,320";$chkLims.Checked=$true $panel.Controls.AddRange(@($chkTest,$chkForm,$chkProd,$chkXplor,$chkLims)) $progress = New-Object System.Windows.Forms.ProgressBar $progress.Location="20,355";$progress.Size="450,20" $panel.Controls.Add($progress) $status = New-Object System.Windows.Forms.Label $status.Location="20,380";$status.Size="450,20";$status.Text="Prêt" $panel.Controls.Add($status) $btnInstall = New-Object System.Windows.Forms.Button $btnInstall.Text="🧩 Installer" $btnInstall.BackColor=[System.Drawing.ColorTranslator]::FromHtml("#2563eb") $btnInstall.ForeColor="white" $btnInstall.Font=New-Object System.Drawing.Font("Segoe UI",10,[System.Drawing.FontStyle]::Bold) $btnInstall.Size="180,40" $btnInstall.Location="20,410" $panel.Controls.Add($btnInstall) $btnSend = New-Object System.Windows.Forms.Button $btnSend.Text="📤 Envoyer Google Sheet" $btnSend.BackColor=[System.Drawing.ColorTranslator]::FromHtml("#16a34a") $btnSend.ForeColor="white" $btnSend.Font=New-Object System.Drawing.Font("Segoe UI",9,[System.Drawing.FontStyle]::Bold) $btnSend.Size="220,40" $btnSend.Location="230,410" $panel.Controls.Add($btnSend) function UI-Update($t,$p){ $status.Text=$t try { $progress.Value=[Math]::Min($p,100) } catch {} $form.Refresh() } # --- INSTALLATION --- $btnInstall.Add_Click({ UI-Update "Détermination du bureau cible..." 5 # Définir DesktopPath selon sélection $selectedType = $cbType.SelectedItem switch ($selectedType) { "Hôpital" { $DesktopPath = "C:\Users\formation1\Desktop" } "Université" { $DesktopPath = "C:\Users\etudiant\Desktop" } "PC hors domaine" { $DesktopPath = "C:\Users\Admin\Desktop" } default { $DesktopPath = "C:\Users\formation1\Desktop" } } Write-Log "DesktopPath défini sur : $DesktopPath" UI-Update "Installation police Barcode..." 10 Install-BarcodeFont UI-Update "Téléchargement et installation du client SILLAGE..." 25 # Installer les différentes cibles selon checkboxes $exe = Join-Path $ProdDir "Sillage.exe" # Installer PROD (téléchargement depuis URL PROD vers ProdDir) if ($chkProd.Checked) { UI-Update "Installation SILLAGE PROD..." 35 if (-not (Install-Sillage $SillageZipUrl $ProdDir)){ [System.Windows.Forms.MessageBox]::Show("Erreur lors de l’installation SILLAGE PROD.","Erreur",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Error) } } # Création des raccourcis (avec le DesktopPath choisi) UI-Update "Création des raccourcis..." 65 if($chkTest.Checked){ # s'assure que Sillage.exe existe (si non, crée quand même le raccourci avec l'URL) Create-SillageShortcut $DesktopPath "SILLAGE TEST" $exe $TestUrl } if($chkForm.Checked){ Create-SillageShortcut $DesktopPath "SILLAGE FORMATION" $exe $FormUrl } if($chkProd.Checked){ Create-SillageShortcut $DesktopPath "SILLAGE PROD" $exe $ProdUrl $ProdIcon } if($chkXplor.Checked){ Create-UrlShortcut $DesktopPath "XPLORE" $XplorUrl } if($chkLims.Checked){ Create-UrlShortcut $DesktopPath "LIMS" $LimsUrl } UI-Update "✅ Installation terminée." 100 }) # --- GOOGLE SHEET --- $btnSend.Add_Click({ try { # récupérer valeurs UI $loc = $txtLoc.Text.Trim() $tag = $txtTag.Text.Trim() $selectedType = $cbType.SelectedItem # Préserver les zéros et ajouter préfixe CR-IT- if (-not [string]::IsNullOrWhiteSpace($tag)) { $tag = "CR-IT-$tag" } else { $tag = "CR-IT-000" } # Collecte d'informations système try { $serial = (Get-CimInstance Win32_BIOS -ErrorAction Stop).SerialNumber } catch { $serial = "UNKNOWN" } $computer = $env:COMPUTERNAME $timestamp = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss") # Adresses MAC $adapters = @() try { $netAdapters = Get-NetAdapter -Physical -ErrorAction Stop foreach ($a in $netAdapters) { $isWifi = ($a.InterfaceDescription -match "Wireless|Wi-?Fi|802\.11") $adapters += [PSCustomObject]@{Name=$a.Name; Mac=$a.MacAddress; Wifi=$isWifi} } } catch { $wmi = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object { $_.MACAddress -ne $null } foreach ($a in $wmi) { $isWifi = ($a.Description -match "Wireless|Wi-?Fi|802\.11") $adapters += [PSCustomObject]@{Name=$a.Name; Mac=$a.MACAddress; Wifi=$isWifi} } } $wlan = $adapters | Where-Object { $_.Wifi } | Select-Object -First 1 $wlanMac = if ($wlan) { $wlan.Mac } else { "" } $allMacs = ($adapters | ForEach-Object { "$($_.Name):$($_.Mac)" }) -join "; " # Construction du payload pour Google Sheet (ajout du Type sélectionné) $payload = @{ Secret = $GoogleSecret Location = $loc Tag = $tag Computer = $computer Serial = $serial WlanMac = $wlanMac AllMacs = $allMacs Type = $selectedType Timestamp = $timestamp } | ConvertTo-Json Invoke-RestMethod -Uri $GoogleAppsScriptURL -Method Post -Body $payload -ContentType "application/json" -ErrorAction Stop [System.Windows.Forms.MessageBox]::Show("✅ Informations envoyées à Google Sheet.`n$tag`n$loc`nType: $selectedType","Succès",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Information) } catch { [System.Windows.Forms.MessageBox]::Show("❌ Erreur lors de l’envoi à Google Sheet:`n$($_.Exception.Message)","Erreur",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Error) } }) [System.Windows.Forms.Application]::EnableVisualStyles() $form.Topmost=$true $form.ShowDialog()
📋 Copy
Close
PowerShell — Google Sheet Script
✕
# ============================================ # CREATION DU RACCOURCI "ifact" # ============================================ $ShortcutName = "IFACT.lnk" $ShortcutURL = "http://10.248.14.161:4200/" # Bureau utilisateur courant $DesktopPath = [Environment]::GetFolderPath("Desktop") $ShortcutPath = Join-Path $DesktopPath $ShortcutName # Bureau formation1 $F1DesktopPath = "C:\Users\formation1\Desktop\$ShortcutName" function New-WebShortcut($Path, $URL) { $wsh = New-Object -ComObject WScript.Shell $sc = $wsh.CreateShortcut($Path) $sc.TargetPath = $URL $sc.IconLocation = "shell32.dll, 220" $sc.Save() } # Crée raccourci pour l’utilisateur courant New-WebShortcut -Path $ShortcutPath -URL $ShortcutURL # Crée raccourci pour formation1 si dossier existe if (Test-Path "C:\Users\formation1\Desktop") { New-WebShortcut -Path $F1DesktopPath -URL $ShortcutURL } Write-Host "Raccourci ifact créé avec succès." Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing # ============================ # GOOGLE SHEET CONFIG # ============================ $GoogleAppsScriptURL = "https://script.google.com/macros/s/AKfycbwhzq3ZZiEKzc_HWQjxCSRq3CMwz-fW9Ax7B_zFGpfwtZ9_2jCBK1Olta0bGCg5u8wN/exec" $GoogleSecret = "MySecureKey123" # ============================ # GET PC INFO # ============================ function Get-PCInfo { $serial = (Get-CimInstance -Class Win32_BIOS).SerialNumber $macs = (Get-CimInstance Win32_NetworkAdapter | Where-Object { $_.MACAddress -and $_.PhysicalAdapter } | Select-Object -ExpandProperty MACAddress) -join "," $wlan = (Get-CimInstance Win32_NetworkAdapter | Where-Object { $_.MACAddress -and $_.Name -like "*Wi*" } | Select-Object -First 1 -ExpandProperty MACAddress) return @{ hostname = $env:COMPUTERNAME serial = $serial macs = $macs wlan = $wlan } } # ============================ # SEND JSON → GOOGLE SHEET # ============================ function Send-ToGoogleSheet { param( [hashtable]$EmpRow, [string]$TagDigits ) $pc = Get-PCInfo $tag = "CR-IT-$TagDigits" $payload = @{ Secret = $GoogleSecret Hostname = $pc.hostname Serial = $pc.serial Macs = $pc.macs Wlan = $pc.wlan Bat = $EmpRow.Bat Etage = $EmpRow.Etage UF = $EmpRow.UF Tag = $tag Date = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss") } | ConvertTo-Json -Depth 5 try { $resp = Invoke-RestMethod ` -Uri $GoogleAppsScriptURL ` -Method POST ` -Body $payload ` -ContentType "application/json" return ($resp -eq "OK") } catch { Write-Host "ERR: $($_.Exception.Message)" -ForegroundColor Red return $false } } # ============================ # EMPLACEMENTS # ============================ $Emplacements = @( @{ Bat="HOP"; Etage="-"; UF="Morgue" } @{ Bat="HOP"; Etage="-"; UF="Unite de caisson hyperbare" } @{ Bat="HOP"; Etage="-"; UF="Logistique commune" } @{ Bat="HOP"; Etage="-"; UF="Antenne BAF Urgences" } @{ Bat="HOP"; Etage="-"; UF="Antenne BAF Oncologie" } @{ Bat="HOP"; Etage="-"; UF="Antenne BAF HDJ / BOP" } @{ Bat="HOP"; Etage="R+1"; UF="Urgences - Gyneco obstetrique" } @{ Bat="HOP"; Etage="R+1"; UF="Bloc obstetrical" } @{ Bat="HOP"; Etage="R+1"; UF="Bloc operatoire central - SSPI Legers" } @{ Bat="HOP"; Etage="R+1"; UF="Bloc operatoire central - SSPI Lourds" } @{ Bat="HOP"; Etage="R+1"; UF="Bloc operatoire central" } @{ Bat="HOP"; Etage="R+1"; UF="Consultation PMA" } @{ Bat="HOP"; Etage="R+1"; UF="Reanimation neonatale - Couveuses" } @{ Bat="HOP"; Etage="R+1"; UF="Unite d'hospitalisation - Coeur Poumon" } @{ Bat="HOP"; Etage="R+1"; UF="PMA Clinique" } @{ Bat="HOP"; Etage="R+1"; UF="PMA Laboratoire" } @{ Bat="HOP"; Etage="R+2"; UF="Reanimation pediatrique" } @{ Bat="HOP"; Etage="R+2"; UF="Soins intensifs neuro vasculaires" } @{ Bat="HOP"; Etage="R+2"; UF="Soins intensifs polyvalents" } @{ Bat="HOP"; Etage="R+2"; UF="Reanimation cardiovasculaire" } @{ Bat="HOP"; Etage="R+2"; UF="Reanimation polyvalente" } @{ Bat="HOP"; Etage="R+2"; UF="Soins intensifs cardiologiques" } @{ Bat="HOP"; Etage="R+3"; UF="Hospitalisation Chirurgie polyvalente" } @{ Bat="HOP"; Etage="R+3"; UF="Medecine physique et readaptation MPR" } @{ Bat="HOP"; Etage="R+3"; UF="Hospitalisation - Reeducation" } @{ Bat="HOP"; Etage="R+3"; UF="Hospitalisation - Medecine" } @{ Bat="HOP"; Etage="R+3"; UF="Hopital de jour" } @{ Bat="HOP"; Etage="R+3"; UF="Endoscopie - SSPI" } @{ Bat="HOP"; Etage="R+3"; UF="Endoscopie" } @{ Bat="HOP"; Etage="R+3"; UF="Consultation HGE" } @{ Bat="HOP"; Etage="R+4"; UF="Centre de check-up" } @{ Bat="HOP"; Etage="R+4"; UF="Hospitalisation - Suites PEP" } @{ Bat="HOP"; Etage="R+4"; UF="Grands brules - Bloc operatoire" } @{ Bat="HOP"; Etage="R+4"; UF="Grands brules - Reanimation" } @{ Bat="HOP"; Etage="R+4"; UF="Grands brules - Soins intensifs" } @{ Bat="HOP"; Etage="R+4"; UF="Grands brules - SSPI" } @{ Bat="HOP"; Etage="R+4"; UF="Grands brules - Balneotherapie" } @{ Bat="HOP"; Etage="R+5"; UF="Hospitalisation - Gyneco obstetrique" } @{ Bat="HOP"; Etage="R+5"; UF="Hospitalisation - Chirurgie pediatrique" } @{ Bat="HOP"; Etage="R+5"; UF="Hospitalisation - Pediatrie" } @{ Bat="HOP"; Etage="R+5"; UF="Hospitalisation - PHCD" } @{ Bat="HOP"; Etage="R+6"; UF="Hemato greffes pediatriques" } @{ Bat="HOP"; Etage="R+6"; UF="Onco hematologie adulte" } @{ Bat="HOP"; Etage="R+6"; UF="Unite sterile - Greffes" } @{ Bat="HOP"; Etage="R+6"; UF="Neurosciences - Tete et Cou" } @{ Bat="HOP"; Etage="RDB"; UF="Medecine nucleaire" } @{ Bat="HOP"; Etage="RDB"; UF="Medecine nucleaire - Iratherapie" } @{ Bat="HOP"; Etage="RDB"; UF="Radiotherapie et chimiotherapie" } @{ Bat="HOP"; Etage="RDB"; UF="Radiotherapie - HDJ" } @{ Bat="HOP"; Etage="RDB"; UF="Radiotherapie - Consultations" } @{ Bat="HOP"; Etage="RDB"; UF="Magasin et quai logistique" } @{ Bat="HOP"; Etage="RDB"; UF="Atelier biomedical" } @{ Bat="HOP"; Etage="RDB"; UF="Pharmacie" } @{ Bat="HOP"; Etage="RDB"; UF="Cuisine hospitaliere" } @{ Bat="HOP"; Etage="RDC"; UF="Sterilisation" } @{ Bat="HOP"; Etage="RDC"; UF="Hemodialyse" } @{ Bat="HOP"; Etage="RDC"; UF="Imagerie diagnostique et interventionnelle" } @{ Bat="HOP"; Etage="RDC"; UF="Anatomopathologie" } @{ Bat="HOP"; Etage="RDC"; UF="Laboratoire hospitalier" } @{ Bat="HOP"; Etage="RDC"; UF="Urgences - Bloc operatoire" } @{ Bat="HOP"; Etage="RDC"; UF="Urgences pediatriques" } @{ Bat="HOP"; Etage="RDC"; UF="Urgences adultes" } @{ Bat="HOP"; Etage="RDC"; UF="Urgences - SSPI" } @{ Bat="HOP"; Etage="RDC"; UF="Urgences - Imagerie" } @{ Bat="HOP"; Etage="RDC"; UF="Urgences - UHCD" } @{ Bat="HOP"; Etage="RDC"; UF="Bureau admissions Central" } @{ Bat="IGH"; Etage="RDC"; UF="Bureau admissions IGH" } @{ Bat="IGH"; Etage="R+1"; UF="Blood center" } @{ Bat="IGH"; Etage="R+1"; UF="Exploration fonctionnelle" } @{ Bat="IGH"; Etage="R+2"; UF="Consultation pneumologie" } @{ Bat="IGH"; Etage="R+2"; UF="Consultation cardiologie" } @{ Bat="IGH"; Etage="R+2"; UF="Chirurgie cardio vasculaire" } @{ Bat="IGH"; Etage="R+2"; UF="Chirurgie thoracique" } @{ Bat="IGH"; Etage="R+2"; UF="Medecine interne" } @{ Bat="IGH"; Etage="R+2"; UF="Chirurgie vasculaire" } @{ Bat="IGH"; Etage="R+3"; UF="Chirurgie plastique reconstructrice" } @{ Bat="IGH"; Etage="R+3"; UF="Consultation dentaire" } @{ Bat="IGH"; Etage="R+3"; UF="Neurologie" } @{ Bat="IGH"; Etage="R+3"; UF="Neurochirurgie" } @{ Bat="IGH"; Etage="R+3"; UF="Traumatologie" } @{ Bat="IGH"; Etage="R+3"; UF="Medecine physique et reeducation" } @{ Bat="IGH"; Etage="R+3"; UF="Pre-anesthesie" } @{ Bat="IGH"; Etage="R+3"; UF="Chirurgie viscerale" } @{ Bat="IGH"; Etage="R+3"; UF="Urologie" } @{ Bat="IGH"; Etage="R+4"; UF="Centre de check-up" } @{ Bat="IGH"; Etage="R+4"; UF="Rhumatologie" } @{ Bat="IGH"; Etage="R+4"; UF="Dermatologie" } @{ Bat="IGH"; Etage="R+4"; UF="Nephrologie" } @{ Bat="IGH"; Etage="R+4"; UF="Endocrinologie" } @{ Bat="IGH"; Etage="R+4"; UF="ORL" } @{ Bat="IGH"; Etage="R+4"; UF="Chirurgie maxillo faciale" } @{ Bat="IGH"; Etage="R+4"; UF="Ophtalmologie" } @{ Bat="IGH"; Etage="R+5"; UF="Gynecologie obstetrique" } @{ Bat="IGH"; Etage="R+5"; UF="Neonatologie" } @{ Bat="IGH"; Etage="R+5"; UF="Chirurgie pediatrique" } @{ Bat="IGH"; Etage="R+5"; UF="Pediatrie" } @{ Bat="IGH"; Etage="R+6"; UF="Hematologie clinique" } @{ Bat="IGH"; Etage="R+6"; UF="Oncologie medicale" } @{ Bat="IGH"; Etage="R+6"; UF="Radiotherapie" } @{ Bat="IGH"; Etage="R+6"; UF="Psychiatrie" } @{ Bat="IGH"; Etage="R+6"; UF="Addictologie" } @{ Bat="IGH"; Etage="R+7"; UF="Administration IGH 7" } @{ Bat="IGH"; Etage="R+8"; UF="Administration IGH 8" } @{ Bat="IGH"; Etage="RDB"; UF="Back-office" } @{ Bat="IGH"; Etage="RDB"; UF="Centre de transfusion sanguine" } @{ Bat="IGH"; Etage="RDB"; UF="Hall accueil - Consultations" } @{ Bat="IGH"; Etage="RDC"; UF="Accueil" } ) | ForEach-Object { [pscustomobject]$_ } # ============================ # UI # ============================ $form = New-Object System.Windows.Forms.Form $form.Text = "PC -> Google Sheet" $form.Size = New-Object System.Drawing.Size(520,380) $form.StartPosition = "CenterScreen" $form.TopMost = $true # BATIMENT $lblBat = New-Object System.Windows.Forms.Label $lblBat.Text = "Batiment" $lblBat.Location = "20,20" $cbBat = New-Object System.Windows.Forms.ComboBox $cbBat.Location = "150,20" $cbBat.Width = 250 $cbBat.DropDownStyle = "DropDownList" # ÉTAGE $lblEtage = New-Object System.Windows.Forms.Label $lblEtage.Text = "Etage" $lblEtage.Location = "20,70" $cbEtage = New-Object System.Windows.Forms.ComboBox $cbEtage.Location = "150,70" $cbEtage.Width = 250 $cbEtage.DropDownStyle = "DropDownList" # SERVICE / UF $lblService = New-Object System.Windows.Forms.Label $lblService.Text = "Service / UF" $lblService.Location = "20,120" $cbService = New-Object System.Windows.Forms.ComboBox $cbService.Location = "150,120" $cbService.Width = 250 $cbService.DropDownStyle = "DropDown" # ALLOW WRITING $cbService.AutoCompleteMode = "SuggestAppend" $cbService.AutoCompleteSource = "ListItems" # TAG $lblTag = New-Object System.Windows.Forms.Label $lblTag.Text = "TAG (CR-IT-XXXX)" $lblTag.Location = "20,170" $txtTag = New-Object System.Windows.Forms.TextBox $txtTag.Location = "150,170" $txtTag.Width = 100 # PREVIEW $lblPreview = New-Object System.Windows.Forms.Label $lblPreview.Text = "Apercu :" $lblPreview.Location = "20,220" $txtPreview = New-Object System.Windows.Forms.TextBox $txtPreview.Location = "150,220" $txtPreview.Width = 300 $txtPreview.ReadOnly = $true # BUTTON $btnSend = New-Object System.Windows.Forms.Button $btnSend.Text = "ENVOYER" $btnSend.Location = "150,270" $btnSend.Width = 200 $form.Controls.AddRange(@( $lblBat,$cbBat,$lblEtage,$cbEtage,$lblService,$cbService, $lblTag,$txtTag,$lblPreview,$txtPreview,$btnSend )) # Load Bat $bats = $Emplacements | Select-Object -ExpandProperty Bat -Unique $cbBat.Items.AddRange($bats) # Load Etage $cbBat.Add_SelectedIndexChanged({ $cbEtage.Items.Clear() $cbService.Items.Clear() $txtPreview.Clear() $etages = ($Emplacements | Where-Object { $_.Bat -eq $cbBat.SelectedItem } | Select-Object -ExpandProperty Etage -Unique) if ($etages) { $cbEtage.Items.AddRange($etages) } }) # Load Services $cbEtage.Add_SelectedIndexChanged({ $cbService.Items.Clear() $txtPreview.Clear() $services = $Emplacements | Where-Object { $_.Bat -eq $cbBat.SelectedItem -and $_.Etage -eq $cbEtage.SelectedItem } | Select-Object -ExpandProperty UF if ($services) { $cbService.Items.AddRange($services) } }) # PREVIEW SYSTEM function Update-Preview { if ($cbBat.SelectedItem -and $cbEtage.SelectedItem -and $cbService.Text.Trim()) { $txtPreview.Text = "$($cbBat.SelectedItem) - $($cbEtage.SelectedItem) - $($cbService.Text.Trim())" } else { $txtPreview.Clear() } } $cbService.Add_TextChanged({ Update-Preview }) $cbService.Add_SelectedIndexChanged({ Update-Preview }) $cbEtage.Add_SelectedIndexChanged({ Update-Preview }) $cbBat.Add_SelectedIndexChanged({ Update-Preview }) # TAG digits only $txtTag.Add_KeyPress({ if (-not [char]::IsControl($_.KeyChar) -and -not [char]::IsDigit($_.KeyChar)) { $_.Handled = $true } }) # SEND BUTTON $btnSend.Add_Click({ if (-not $cbBat.SelectedItem -or -not $cbEtage.SelectedItem -or -not $cbService.Text.Trim()) { [System.Windows.Forms.MessageBox]::Show("Veuillez remplir tous les champs.","Info manquante") return } if (-not $txtTag.Text.Trim()) { [System.Windows.Forms.MessageBox]::Show("TAG manquant.","Erreur") return } $row = @{ Bat = $cbBat.SelectedItem Etage = $cbEtage.SelectedItem UF = $cbService.Text.Trim() # WRITTEN OR SELECTED } $done = Send-ToGoogleSheet -EmpRow $row -TagDigits $txtTag.Text.Trim() if ($done) { [System.Windows.Forms.MessageBox]::Show("Envoyé avec succès","Succès") } else { [System.Windows.Forms.MessageBox]::Show("Erreur d'envoi.","Erreur") } }) # RUN UI $form.ShowDialog()
📋 Copy
Close