fixed restore inf driver

This commit is contained in:
duffyduck 2026-02-11 21:00:42 +01:00
parent 5f67657eb7
commit ddfe77154a
1 changed files with 19 additions and 8 deletions

View File

@ -187,9 +187,14 @@ function Get-PrinterDriverDetails {
$driverInfo.PrintProcessor = $driver.PrintProcessor
# Paketverzeichnis aus INF-Pfad ableiten
# System-INFs wie delegwiz.inf ausfiltern - das sind keine echten Treiber-INFs
$systemInfs = @('delegwiz.inf', 'ntprint.inf', 'prnms001.inf', 'prnms002.inf')
if ($driver.InfPath -and (Test-Path $driver.InfPath)) {
$driverInfo.PackageDirectory = Split-Path -Parent $driver.InfPath
$driverInfo.InfFileName = Split-Path -Leaf $driver.InfPath
$infName = Split-Path -Leaf $driver.InfPath
if ($systemInfs -notcontains $infName.ToLower()) {
$driverInfo.PackageDirectory = Split-Path -Parent $driver.InfPath
$driverInfo.InfFileName = $infName
}
}
# Einzelne Treiberdateien sammeln
@ -592,11 +597,13 @@ function Restore-PrinterDriver {
}
# Treiber-Backup-Verzeichnis finden
$safeDirName = $driverName -replace '[\\/:*?"<>|]', '_'
$driverBackupDir = Join-Path $BackupTempDir "drivers" $safeDirName
$safeDirName = $driverName -replace '[\\/:*?"<>|]', '_'
$driversBaseDir = Join-Path $BackupTempDir "drivers"
$driverBackupDir = Join-Path $driversBaseDir $safeDirName
if (-not (Test-Path $driverBackupDir)) {
if (-not (Test-Path -LiteralPath $driverBackupDir)) {
Write-Log " Fehler: Treiberdateien fuer '$driverName' nicht in der Sicherung!" "ERROR"
Write-Log " Gesucht in: $driverBackupDir"
Write-Log " -> Bitte installieren Sie den Treiber manuell."
return $false
}
@ -604,18 +611,22 @@ function Restore-PrinterDriver {
# Methode 1: INF-basierte Installation (bevorzugt)
$infPath = $null
# Zuerst die gespeicherte INF-Datei aus dem Backup verwenden
if ($DriverData.BackupInfPath) {
$testInf = Join-Path $driverBackupDir $DriverData.BackupInfPath
if (Test-Path $testInf) {
if (Test-Path -LiteralPath $testInf) {
$infPath = $testInf
}
}
# INF-Datei im Backup suchen falls nicht gefunden
# System-INFs wie delegwiz.inf, ntprint.inf etc. ausfiltern
if (-not $infPath) {
$infFiles = Get-ChildItem -Path $driverBackupDir -Filter "*.inf" -Recurse -ErrorAction SilentlyContinue
$systemInfs = @('delegwiz.inf', 'ntprint.inf', 'prnms001.inf', 'prnms002.inf')
$infFiles = Get-ChildItem -LiteralPath $driverBackupDir -Filter "*.inf" -Recurse -ErrorAction SilentlyContinue |
Where-Object { $systemInfs -notcontains $_.Name.ToLower() }
if ($infFiles) {
$infPath = $infFiles[0].FullName
$infPath = @($infFiles)[0].FullName
}
}