Skip to content

OscarTired/Unlock-PDFs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

PDF Preview Fix for Windows

Windows PowerShell License Status

Overview

Fix Windows file preview issues where PDFs show the warning: "The file you are trying to preview could harm your computer. If you trust the file and its origin, you can open it to view the content."

This solution unlocks blocked PDF files in bulk using PowerShell, enabling instant preview without manually unblocking each file.


Prerequisites

PowerShell Version Admin Rights

  • Windows 10/11
  • PowerShell 5.1 or higher
  • Administrator privileges

Quick Start

Step 1: Open PowerShell

Caution

Run PowerShell in Administrator Mode

Press Windows + X and select "Windows PowerShell (Admin)" or "Terminal (Admin)"

Step 2: Navigate to Target Folder

Navigate to the folder where your PDFs are located:

cd "C:\path\to\your\folder"

Example:

cd "C:\Users\YourName\Documents\PDFs"

Step 3: Unblock All PDFs

Run this command to unlock all PDFs recursively:

Get-ChildItem -Path . -Recurse -Filter *.pdf | Unblock-File

Step 4: Refresh File Explorer

Close and reopen File Explorer to see the changes take effect.


Alternative Commands

Unblock All Files (Not Just PDFs)

Get-ChildItem -Path . -Recurse | Unblock-File

Unblock Files in Specific Directory Only (Non-Recursive)

Get-ChildItem -Path . -Filter *.pdf | Unblock-File

Unblock a Single File

Unblock-File -Path "C:\path\to\file.pdf"

Permanent Solution

To prevent Windows from blocking downloaded files in the future:

  1. Open Registry Editor (regedit)
  2. Navigate to:
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments
    
  3. Create a new DWORD (32-bit) Value:
    • Name: SaveZoneInformation
    • Value: 1
  4. Restart File Explorer

Troubleshooting

Issue Solution
"Access Denied" Ensure PowerShell is running as Administrator
Command not found Verify PowerShell version is 5.1+ with $PSVersionTable
Preview still blocked Restart File Explorer or reboot the system
Registry key missing Create the Attachments key manually under Policies

License

MIT License

This project is licensed under the MIT License - feel free to use and modify as needed.


Acknowledgments

Thanks to the Windows community for discovering these registry tweaks and PowerShell solutions!


Happy Previewing!

Releases

No releases published

Packages

 
 
 

Contributors