# WJDT Printer Installer

Universal printer installer for network printers and card printers from ShopDB database.

## Overview

This Inno Setup installer queries the ShopDB database for HP, Xerox, Brother, and HID printers, allows users to select which printers to install, and automatically:
- Installs appropriate printer drivers (HP UPD, Xerox Universal, Brother MFC, HID FARGO DTC4500e)
- Creates TCP/IP Standard Printer Ports for network printers using FQDN or IP addresses
- Installs USB drivers for card printers (plug-and-play after driver installation)
- Adds selected printers to Windows

## Features

- **Database Integration**: Queries ShopDB database via REST API at `http://192.168.122.151:8080/api_printers.asp`
- **Multi-Printer Selection**: Checkbox interface to select one or more printers (network or card printers)
- **Smart Driver Installation**:
  - HP Universal Print Driver PCL6 (x64 v7.9.0 and x32 v7.9.0)
  - Xerox Universal Print Driver PCL6 (x64 v5.1055.3.0 and x32 v5.1055.3.0)
  - Brother MFC-J5845DW GDI Driver (multi-arch, staged via DPInst)
  - HID FARGO DTC4500e Card Printer Driver (x64 v5.5.0.0)
  - Automatically selects correct driver based on Windows architecture
- **Network Printer Support**: Uses printer FQDN (preferred) or IP address for TCP/IP connectivity
- **Card Printer Support**: USB-connected badge/ID card printers (HID FARGO)
- **Professional UI**: Custom branding with GEA logo and Patrick artwork
- **Admin Installation**: Requires administrator privileges

## Requirements

### To Build
- Inno Setup 6.x installed on Windows
- Printer drivers in `drivers/` subdirectories (already included)
- Access to build machine

### To Run
- Windows 10/11 (32-bit or 64-bit)
- Administrator privileges
- Network access to ShopDB server (192.168.122.151:8080)

## Project Structure

```
PrinterInstaller/
├── PrinterInstaller.iss         # Main Inno Setup script
├── README.md                     # This file
├── gea-logo.ico                  # Application icon
├── patrick.bmp                   # Large wizard image (164x314px)
├── patrick-sm.bmp                # Small wizard image (55x58px)
└── drivers/
    ├── hp_x64/                   # HP Universal Print Driver x64
    │   ├── hpcu345u.inf          # Main driver INF file
    │   └── ...                   # Supporting files
    ├── hp_x32/                   # HP Universal Print Driver x32
    │   ├── hpcu345u.inf
    │   └── ...
    ├── xerox_x64/                # Xerox Universal Print Driver x64
    │   └── UNIV_5.1055.3.0_PCL6_x64_Driver.inf/
    │       ├── x3UNIVX.inf       # Main driver INF file
    │       └── ...
    ├── xerox_x32/                # Xerox Universal Print Driver x32
    │   ├── x3UNIVX.inf           # Main driver INF file
    │   └── ...
    ├── brother/                  # Brother MFC GDI Driver (multi-arch)
    │   ├── amd64/                # x64 compressed DLLs
    │   ├── i386/                 # x32 compressed DLLs
    │   ├── brpoi16a.inf          # Port driver INF
    │   ├── dpinstx64.exe         # DPInst installer (x64)
    │   ├── dpinstx86.exe         # DPInst installer (x32)
    │   ├── dpinst.xml            # DPInst quiet-install config
    │   └── ...                   # Model data (.da_), driver DLLs (.dl_)
    └── hid_dtc4500e_x64/         # HID FARGO DTC4500e Card Printer x64
        ├── DTC4500e.inf          # Main driver INF file
        ├── DTC4500e_x64.cat      # Digital signature catalog
        └── ...                   # Supporting DLLs and files
```

## Building the Installer

### On Windows

1. Open Inno Setup Compiler
2. File → Open → Select `PrinterInstaller.iss`
3. Build → Compile (or press F9)
4. Output file created at: `C:\Users\570005354\Downloads\Output\PrinterInstaller.exe`

### Command Line

```batch
"C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "C:\path\to\PrinterInstaller.iss"
```

## Installation Process

When a user runs `PrinterInstaller.exe`:

1. **Welcome Page**: Explains what the installer does
2. **Query Database**: Fetches list of active HP/Xerox/Brother printers from ShopDB
3. **Printer Selection**: User selects which printers to install (checkboxes)
4. **Ready Page**: Confirms selections
5. **Driver Installation**:
   - Extracts drivers to temp folder
   - Uses `pnputil` to add driver packages
   - Adds print drivers with `Add-PrinterDriver`
6. **Printer Installation**:
   - Creates TCP/IP printer ports for each printer
   - Adds printers with appropriate drivers
7. **Summary**: Shows installation results

## How It Works

### Database Query

The installer queries the ShopDB API which returns JSON:

```json
[
  {
    "printerid": 6,
    "printerwindowsname": "Coaching 112 LaserJet M254dw",
    "fqdn": "Printer-10-80-92-52.printer.geaerospace.net",
    "ipaddress": "10.80.92.52",
    "vendor": "HP",
    "modelnumber": "Color LaserJet M254dw",
    "isactive": 1
  },
  ...
]
```

### Driver Mapping

| Vendor | Driver Name | INF File (x64) | INF File (x32) |
|--------|-------------|----------------|----------------|
| HP | HP Universal Printing PCL 6 | `hpcu345u.inf` | `hpcu345u.inf` |
| Xerox | Xerox Global Print Driver PCL6 | `x3UNIVX.inf` | `x3UNIVX.inf` |
| Brother | Brother MFC-J5845DW | `brpoi16a.inf` | `brpoi16a.inf` |

**Note**: Brother uses DPInst (`dpinstx64.exe`/`dpinstx86.exe`) instead of pnputil for driver staging, as the MFC-J inkjet driver uses proprietary GDI rendering with no Printer class INF.

### Printer Port Naming

Format: `IP_<FQDN or IP Address>`

Examples:
- `IP_Printer-10-80-92-52.printer.geaerospace.net`
- `IP_10.80.92.52`

## Supported Printers

### HP Models (23 printers)
- Color LaserJet M254dw
- Color LaserJet M255dw
- HP DesignJet T1700dr PS
- LaserJet 4250tn
- LaserJet M406
- LaserJet M454dn
- LaserJet M506
- LaserJet M602
- LaserJet P3015dn
- LaserJet Pro 4001n
- LaserJet Pro 4100dn
- And more...

### Xerox Models (12 printers)
- Altalink C8135
- Versalink B405DN
- Versalink B7125
- Versalink C7125
- Xerox EC8036

### Brother Models
- MFC-J5845DW

### HID Card Printers (USB)
- **HID FARGO DTC4500e** - Dual-sided card printer for badge/ID printing
  - Connection: USB
  - Driver installed, device auto-configures on USB connection
  - Used for employee badges, access cards, ID cards

## Command-Line Parameters

### Auto-Select Specific Printer

Pre-select a specific printer by name using the `/PRINTER` parameter:

```batch
PrinterInstaller.exe /PRINTER="CSF04-WJWT05-ColorLaserJetM254dw"
```

This will:
- Launch the installer normally
- Automatically check the matching printer(s) in the selection list
- Allow user to proceed with installation or modify selection

**Use cases:**
- Create direct download links for specific printers on your website
- QR codes that install specific printers
- Department-specific installer shortcuts

**Partial matching supported:**
```batch
PrinterInstaller.exe /PRINTER="CSF04"      # Matches CSF04-WJWT05-ColorLaserJetM254dw
PrinterInstaller.exe /PRINTER="Coaching"   # Matches all Coaching printers
PrinterInstaller.exe /PRINTER="LaserJet"   # Matches all LaserJet printers
```

### Silent Installation

Run installer silently (no UI):

```batch
PrinterInstaller.exe /VERYSILENT /NORESTART
```

Combine with auto-select for fully automated installation:

```batch
PrinterInstaller.exe /PRINTER="CSF04" /VERYSILENT /NORESTART
```

## Troubleshooting

### "Failed to query printers"
- Check network connectivity
- Verify ShopDB server is accessible at `http://192.168.122.151:8080`
- Test API manually: `http://192.168.122.151:8080/api_printers.asp`

### "Driver installation failed"
- Ensure running as Administrator
- Check Windows version compatibility
- Verify driver files are present in `drivers/` folder

### "Printer already exists"
- Normal behavior - installer skips existing printers
- Delete printer from Windows first if you want to reinstall

### Multiple Architecture Support
- HP and Xerox drivers have separate x86/x64 packages; Brother includes both in one package
- Installer automatically detects Windows architecture and uses appropriate drivers
- All printers (HP, Xerox, and Brother) work on both 32-bit and 64-bit systems

## API Endpoint

The installer expects a REST API at:

```
GET http://192.168.122.151:8080/api_printers.asp
```

Returns JSON array of printer objects with fields:
- `printerid` (number)
- `printerwindowsname` (string)
- `fqdn` (string)
- `ipaddress` (string)
- `vendor` (string: "HP", "Xerox", or "Brother")
- `modelnumber` (string)
- `isactive` (number: 1 or 0)

## Customization

### Change Database Server

Edit `PrinterInstaller.iss` line 67:

```pascal
'    $url = "http://YOUR-SERVER:PORT/api_printers.asp"' + #13#10 +
```

### Add More Vendors

1. Add driver files to `drivers/` folder
2. Update `[Files]` section to include new drivers
3. Modify `Install-PrinterDriver` function to support new vendor
4. Update `Install-NetworkPrinter` function for driver mapping

### Change Branding

Replace these files:
- `gea-logo.ico` - Application icon (32x32 or 48x48)
- `patrick.bmp` - Large wizard image (164x314px)
- `patrick-sm.bmp` - Small wizard image (55x58px)

## Version History

### Version 1.0 (2025-10-15)
- Initial release
- Support for HP and Xerox printers
- Database integration with ShopDB
- TCP/IP installation via FQDN
- x64 and x32 architecture support
- HP Universal Print Driver v7.9.0
- Xerox Global Print Driver v5.1055.3.0

## Credits

- **Development**: WJDT
- **Template**: Based on MappedDrive.iss
- **Drivers**: HP Inc., Xerox Corporation, Brother Industries
- **Installer Framework**: Inno Setup by Jordan Russell

## License

Internal use only - WJDT / GE Aerospace
