Ajout de la langue anglaise
Ajout d'un README.md avec le descriptif et les instructions L'ancien README.md s'appelle désormais CHANGELOG.md Activation du pavé numérique par défaut pour les installations sans assistance Nouveau design pour la fenêtre de déploiement. Ajout de paramètre pour pouvoir procéder à une installation totalement automatisée Ajout de paramètre pour copier au choix sources, drivers ou les deux sur C:\DeployVenter avant leur usage par DISM.
This commit is contained in:
1 parent
cb917c97ce
commit
2212e25d31
26 files changed
+2625
-830
No files matched your search
+33
-33
@@ -1,5 +1,5 @@
|
||||
# Module VNC de DeployCenter
|
||||
# Exécuté uniquement avec -Vnc dans le scope principal pour partager le contexte WinPE.
|
||||
# DeployCenter VNC module
|
||||
# Run only with -Vnc in the main scope to share the WinPE context.
|
||||
|
||||
function Start-DeployCenterVnc {
|
||||
$parentRoot = Split-Path -Path $script:DeployRoot -Parent
|
||||
@@ -9,36 +9,36 @@ function Start-DeployCenterVnc {
|
||||
$sourceIni = Join-Path $sourceVnc 'ultravnc.ini'
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($script:DeployIPv4)) {
|
||||
& $script:SourceLogAction 'Aucune adresse IPv4 de déploiement détectée.' 'WARNING'
|
||||
& $script:SourceLogAction 'No deployment IPv4 address detected.' 'WARNING'
|
||||
}
|
||||
|
||||
if (-not (Test-Path -LiteralPath $sourceExe -PathType Leaf)) {
|
||||
& $script:SourceLogAction "UltraVNC non démarré : exécutable absent ($sourceExe)." 'WARNING'
|
||||
& $script:SourceLogAction "UltraVNC was not started: executable not found ($sourceExe)." 'WARNING'
|
||||
Write-DeployInventory -InventoryDir $script:InventoryDir -InventoryFile $script:InventoryFile -HardwareInfo $script:HardwareInventory -DeploymentIPv4 $script:DeployIPv4 -VncPassword $script:VncPassword -LogAction $script:SourceLogAction
|
||||
return
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $passwordTool -PathType Leaf)) {
|
||||
& $script:SourceLogAction "UltraVNC non démarré : createpassword64.exe absent ($passwordTool)." 'WARNING'
|
||||
& $script:SourceLogAction "UltraVNC was not started: createpassword64.exe absent ($passwordTool)." 'WARNING'
|
||||
Write-DeployInventory -InventoryDir $script:InventoryDir -InventoryFile $script:InventoryFile -HardwareInfo $script:HardwareInventory -DeploymentIPv4 $script:DeployIPv4 -VncPassword $script:VncPassword -LogAction $script:SourceLogAction
|
||||
return
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $sourceIni -PathType Leaf)) {
|
||||
& $script:SourceLogAction "UltraVNC non démarré : fichier absent ($sourceIni)." 'WARNING'
|
||||
& $script:SourceLogAction "UltraVNC was not started: file not found ($sourceIni)." 'WARNING'
|
||||
Write-DeployInventory -InventoryDir $script:InventoryDir -InventoryFile $script:InventoryFile -HardwareInfo $script:HardwareInventory -DeploymentIPv4 $script:DeployIPv4 -VncPassword $script:VncPassword -LogAction $script:SourceLogAction
|
||||
return
|
||||
}
|
||||
|
||||
$vncStage = 'préparation du dossier temporaire'
|
||||
$vncStage = 'preparing the temporary folder'
|
||||
try {
|
||||
if (Test-Path -LiteralPath $script:VncDirectory) {
|
||||
Remove-Item -LiteralPath $script:VncDirectory -Recurse -Force -ErrorAction Stop
|
||||
}
|
||||
New-Item -Path $script:VncDirectory -ItemType Directory -Force | Out-Null
|
||||
$vncStage = "copie des fichiers depuis $sourceVnc vers $script:VncDirectory"
|
||||
$vncStage = "copying files from $sourceVnc to $script:VncDirectory"
|
||||
Copy-Item -Path (Join-Path $sourceVnc '*') -Destination $script:VncDirectory -Recurse -Force
|
||||
# WinPE ne permet pas toujours d'ajouter des règles de pare-feu.
|
||||
# La désactivation globale n'est effectuée que lorsque VNC est demandé.
|
||||
$vncStage = 'désactivation du pare-feu WinPE'
|
||||
# WinPE does not always allow firewall rules to be added.
|
||||
# The firewall is disabled globally only when VNC is requested.
|
||||
$vncStage = 'disabling the WinPE firewall'
|
||||
$wpeutil = Join-Path $env:WINDIR 'System32\wpeutil.exe'
|
||||
if (-not (Test-Path -LiteralPath $wpeutil -PathType Leaf)) {
|
||||
$wpeutil = 'wpeutil.exe'
|
||||
@@ -48,58 +48,58 @@ function Start-DeployCenterVnc {
|
||||
foreach ($outputLine in $wpeutilOutput) {
|
||||
$outputText = [string]$outputLine
|
||||
if (-not [string]::IsNullOrWhiteSpace($outputText)) {
|
||||
& $script:SourceLogAction "wpeutil DisableFirewall : $outputText" 'INFO'
|
||||
& $script:SourceLogAction "wpeutil DisableFirewall: $outputText" 'INFO' $true
|
||||
}
|
||||
}
|
||||
if ($wpeutilExitCode -ne 0) {
|
||||
throw "wpeutil DisableFirewall a renvoyé le code $wpeutilExitCode."
|
||||
throw "wpeutil DisableFirewall returned exit code $wpeutilExitCode."
|
||||
}
|
||||
& $script:SourceLogAction "Pare-feu WinPE désactivé à la demande de -Vnc (code wpeutil : $wpeutilExitCode)." 'WARNING'
|
||||
& $script:SourceLogAction "WinPE firewall disabled at the request of -Vnc (wpeutil exit code: $wpeutilExitCode)." 'WARNING'
|
||||
|
||||
# Force le mode portable : l'INI actif est celui placé à côté de winvnc.exe.
|
||||
$vncStage = 'activation du mode portable UltraVNC'
|
||||
# Force portable mode: the active INI is the one next to winvnc.exe.
|
||||
$vncStage = 'enabling UltraVNC portable mode'
|
||||
$portableFlag = Join-Path $script:VncDirectory 'ultravnc.portable'
|
||||
Set-Content -LiteralPath $portableFlag -Value '' -Encoding ASCII
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace([string]$script:Config.VncPassword)) {
|
||||
$script:VncPassword = [string]$script:Config.VncPassword
|
||||
$passwordSource = 'configuré dans DeployCenter.ini'
|
||||
$passwordSource = 'configured in DeployCenter.ini'
|
||||
}
|
||||
else {
|
||||
$script:VncPassword = -join (1..8 | ForEach-Object {
|
||||
$alphabet = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789'
|
||||
$alphabet[(Get-Random -Minimum 0 -Maximum $alphabet.Length)]
|
||||
})
|
||||
$passwordSource = 'généré automatiquement'
|
||||
$passwordSource = 'generated automatically'
|
||||
}
|
||||
|
||||
# createpassword64 encode le mot de passe choisi dans le champ passwd d'ultravnc.ini.
|
||||
$vncStage = 'génération du mot de passe UltraVNC'
|
||||
# createpassword64 encodes the selected password in the passwd field of ultravnc.ini.
|
||||
$vncStage = 'generating the UltraVNC password'
|
||||
$tool = Join-Path $script:VncDirectory 'createpassword64.exe'
|
||||
$script:VncProcess = Start-Process -FilePath $tool -ArgumentList @($script:VncPassword) `
|
||||
-WorkingDirectory $script:VncDirectory -Wait -PassThru -WindowStyle Hidden
|
||||
if ($script:VncProcess.ExitCode -ne 0) {
|
||||
throw "createpassword64.exe a renvoyé le code $($script:VncProcess.ExitCode)."
|
||||
throw "createpassword64.exe returned exit code $($script:VncProcess.ExitCode)."
|
||||
}
|
||||
|
||||
$activeIni = Join-Path $script:VncDirectory 'ultravnc.ini'
|
||||
if (-not (Test-Path -LiteralPath $activeIni -PathType Leaf) -or
|
||||
-not (Select-String -LiteralPath $activeIni -Pattern '^passwd\s*=' -Quiet)) {
|
||||
throw "createpassword64.exe n'a pas créé le champ passwd dans ultravnc.ini."
|
||||
throw "createpassword64.exe did not create the passwd field in ultravnc.ini."
|
||||
}
|
||||
|
||||
$server = Join-Path $script:VncDirectory 'winvnc.exe'
|
||||
$vncStage = 'démarrage du serveur UltraVNC'
|
||||
$vncStage = 'starting the UltraVNC server'
|
||||
$script:VncProcess = Start-Process -FilePath $server -ArgumentList @('-run') `
|
||||
-WorkingDirectory $script:VncDirectory -PassThru -WindowStyle Hidden
|
||||
Start-Sleep -Milliseconds 800
|
||||
if ($script:VncProcess.HasExited) {
|
||||
throw "winvnc.exe s'est arrêté immédiatement (code $($script:VncProcess.ExitCode))."
|
||||
throw "winvnc.exe exited immediately (code $($script:VncProcess.ExitCode))."
|
||||
}
|
||||
$script:VncStarted = $true
|
||||
& $script:SourceLogAction "UltraVNC démarré. IP : $($script:DeployIPv4) ; mot de passe $passwordSource." 'SUCCESS'
|
||||
& $script:SourceLogAction "UltraVNC started. IP: $($script:DeployIPv4) ; password $passwordSource." 'SUCCESS'
|
||||
} catch {
|
||||
& $script:SourceLogAction "Échec du démarrage UltraVNC à l'étape '$vncStage' : $($_.Exception.Message)" 'ERROR'
|
||||
& $script:SourceLogAction "UltraVNC startup failed at stage '$vncStage' : $($_.Exception.Message)" 'ERROR'
|
||||
$script:VncStarted = $false
|
||||
$script:VncPassword = $null
|
||||
}
|
||||
@@ -112,20 +112,20 @@ function Stop-DeployCenterVnc {
|
||||
$proc = Get-Process -Id $script:VncProcess.Id -ErrorAction SilentlyContinue
|
||||
if ($null -ne $proc) { Stop-Process -Id $proc.Id -Force -ErrorAction SilentlyContinue }
|
||||
}
|
||||
# Au cas où winvnc lance un processus serveur distinct, ne cibler que les
|
||||
# processus dont le chemin correspond à notre copie temporaire.
|
||||
# If winvnc starts a separate server process, target only processes
|
||||
# whose executable path matches our temporary copy.
|
||||
foreach ($proc in (Get-CimInstance Win32_Process -Filter "Name='winvnc.exe'" -ErrorAction SilentlyContinue)) {
|
||||
if ($proc.ExecutablePath -and $proc.ExecutablePath.StartsWith($script:VncDirectory, [StringComparison]::OrdinalIgnoreCase)) {
|
||||
Stop-Process -Id $proc.ProcessId -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
& $script:SourceLogAction "Arrêt UltraVNC : $($_.Exception.Message)" 'WARNING'
|
||||
& $script:SourceLogAction "Stopping UltraVNC: $($_.Exception.Message)" 'WARNING'
|
||||
}
|
||||
# Le processus winvnc peut conserver brièvement un handle sur son dossier.
|
||||
# Le dossier VNC est propre à ce processus PowerShell (uvnc_<PID>) : on ne
|
||||
# supprime pas récursivement le dossier partagé InventoryDir, ce qui évite
|
||||
# de bloquer le lancement suivant si un handle est encore ouvert.
|
||||
# The winvnc process may briefly keep a handle open on its folder.
|
||||
# The VNC folder belongs to this PowerShell process (uvnc_<PID>); do not
|
||||
# recursively delete the shared InventoryDir folder. This avoids
|
||||
# blocking the next launch if a handle is still open.
|
||||
try {
|
||||
if (Test-Path -LiteralPath $script:InventoryFile -PathType Leaf) {
|
||||
Remove-Item -LiteralPath $script:InventoryFile -Force -ErrorAction SilentlyContinue
|
||||
|
||||
Reference in new issue
Block a user