landscape, field, fantasy

Windows Explorer Preview Handlers: Automated Installation Guide

This guide will walk you through automating the installation of preview handlers for Explorer using and Chocolatey. Preview handlers are essential components that allow you to preview files directly in Windows Explorer without opening them in their native applications. The provided streamlines the installation process by automating the setup of multiple preview handlers for different file types.

What the Script Does

This performs several key tasks:

  • Installs Prerequisites: The script checks for and installs Chocolatey if not already present on the system
  • PDF Preview: Installs and configures SumatraPDF for quick PDF previews in Explorer
  • 3D File Preview: Sets up OpenSCAD for previewing STL, GCODE, and 3MF files
  • Video Preview: Configures VLC media player for video file previews
  • Explorer Integration: Automatically registers all preview handlers with Windows Explorer
  • System Restart: Gracefully restarts Explorer to apply all changes

This ensures that you can quickly preview supported files directly in Explorer’s preview pane, improving workflow efficiency and .

PowerShell Script

# Windows Explorer Preview Handler Installer
# Author: Wes Ellis
# Website: wesellis.com
#
# Description: This script installs and configures preview handlers for Windows Explorer
# allowing preview of the following file types:
# - PDF files using SumatraPDF
# - 3D files (.stl, .gcode, .3mf) using OpenSCAD
# - Video files using VLC
#
# Requires admin rights and Chocolatey package manager (auto-installs if missing)

# Requires -RunAsAdministrator

function Show-Banner {
    param (
        [string]$text
    )
    Write-Host @"
╔════════════════════════════════════════════════╗
$($text.PadRight(46))
╚════════════════════════════════════════════════╝
"@ -ForegroundColor Yellow
}

function Show-Progress {
    param (
        [int]$percent
    )
    Write-Host "[" -NoNewline
    for ($i = 0; $i -lt 20; $i++) {
        if ($i -lt ($percent / 5)) {
            Write-Host "█" -NoNewline -ForegroundColor Green
        } else {
            Write-Host "░" -NoNewline -ForegroundColor DarkGray
        }
    }
    Write-Host "] $percent%" -ForegroundColor Cyan
}

function Install-PreviewHandlers {
    try {
        Show-Banner "EXPLORER PREVIEW INSTALLER"
        Show-Progress 0
        
        # Install Chocolatey if needed
        if (!(Get-Command choco -ErrorAction SilentlyContinue)) {
            [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
            Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | Out-Null
        }

        # PDF Preview
        Show-Banner "INSTALLING PDF PREVIEW"
        $null = choco install sumatrapdf.install -y --limit-output --no-progress
        $null = cmd /c "ftype PDF=`"${env:ProgramFiles}\SumatraPDF\SumatraPDF.exe`" `"%1`"" 2>&1
        $null = cmd /c "assoc .pdf=PDF" 2>&1
        Show-Progress 33

        # 3D Preview 
        Show-Banner "INSTALLING 3D PREVIEW"
        $null = choco install openscad -y --limit-output --no-progress
        $null = cmd /c "assoc .stl=OpenSCAD.stl" 2>&1
        $null = cmd /c "assoc .gcode=OpenSCAD.gcode" 2>&1
        $null = cmd /c "assoc .3mf=OpenSCAD.3mf" 2>&1
        Show-Progress 66

        # Video Preview
        Show-Banner "INSTALLING VIDEO PREVIEW"
        $null = choco install vlc -y --limit-output --no-progress
        Show-Progress 90

        # Restart Explorer
        Show-Banner "APPLYING CHANGES"
        Stop-Process -Name "explorer" -Force -ErrorAction SilentlyContinue
        Start-Sleep -Seconds 2
        Start-Process "explorer.exe"
        Show-Progress 100

        Show-Banner "INSTALLATION COMPLETE"
    }
    catch {
        Show-Banner "ERROR"
        Write-Host $_.Exception.Message -ForegroundColor Red
        exit 1
    }
}

Install-PreviewHandlers

Instructions

  1. Run as Administrator: The script requires administrative privileges to install and modify system settings.
  2. Enable Preview Pane: After installation, ensure the Preview Pane is enabled in Windows Explorer (View > Preview Pane).
  3. Installation Process: The script will:
  • Check for and install Chocolatey if needed
  • Install PDF preview capabilities
  • Configure 3D file preview support
  • Set up video preview functionality
  • Restart Explorer to apply changes
  1. Progress Tracking: The script provides visual feedback with progress bars and status messages during installation.

Supported File Types

  • PDF Files: Preview PDF documents using SumatraPDF
  • 3D Models: Preview .stl, .gcode, and .3mf files using OpenSCAD
  • Video Files: Preview video content using VLC media player

Tags:

# #PowerShell # #Automation #

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

WordPress Cookie Plugin by Real Cookie Banner