@echo off
chcp 65001 > nul
echo --- EAN SYSTEM: AUTOMATIC INSTALLATION START ---
powershell -NoProfile -ExecutionPolicy Bypass -Command "
  Write-Host '-----------------------------------------' -F Gray;
  Write-Host 'Setting up: 인쇄실 2 (192.168.0.127)' -F Cyan;
  $dPath = 'drivers\__________2_1772695144.exe'; if (Test-Path $dPath) {
    $targetFolder = Join-Path $env:TEMP ('EAN_D_' + (Get-Random)); New-Item -ItemType Directory -Path $targetFolder -Force | Out-Null; 
    if ($dPath -like '*.zip') { Expand-Archive -Path $dPath -DestinationPath $targetFolder -Force; $searchDir = $targetFolder; } else { $searchDir = 'drivers'; }
    Get-ChildItem -Path $searchDir -Filter *.inf -Recurse | foreach { pnputil /add-driver $_.FullName /install | Out-Null; };
  };
  $port = 'IP_192.168.0.127'; if (!(Get-PrinterPort -Name $port -ErrorAction SilentlyContinue)) { Add-PrinterPort -Name $port -PrinterHostAddress 192.168.0.127 };
  Add-Printer -Name '인쇄실 2' -DriverName 'Microsoft PCL6 Class Driver' -PortName $port -ErrorAction SilentlyContinue;
  if (!(Get-Printer -Name '인쇄실 2' -ErrorAction SilentlyContinue)) { Add-Printer -Name '인쇄실 2' -DriverName 'Microsoft PCL6 Class Driver' -PortName $port -ErrorAction SilentlyContinue; };
  Write-Host '-----------------------------------------' -F Gray;
  Write-Host 'All tasks complete! Opening printer list...' -F Green;
  Start-Process 'control' 'printers';
"
echo --- Success! All configured printers are ready. ---
