Created
February 28, 2025 23:00
-
-
Save nestorcolt/012d1ee929d659019fa7815a3fc735e4 to your computer and use it in GitHub Desktop.
Remove HOME, GALLERY & ONEDRIVE from Explorer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
=============================================================== | |
PowerShell Script: Toggle Gallery, Home, and OneDrive in File Explorer | |
Author: ChatGPT (AI Assistant) | |
Date: 2025 | |
Tested On: Windows 11 (Latest Build) | |
=============================================================== | |
What This Script Does: | |
- Properly removes or restores Gallery by modifying CLSID Registry. | |
- Removes or Restores Home from File Explorer. | |
- Removes or Restores OneDrive from File Explorer. | |
- Restarts Explorer to apply changes immediately. | |
Registry Keys Modified: | |
- Gallery → CLSID Key: | |
HKEY_CURRENT_USER\Software\Classes\CLSID\{e88865ea-0e1c-4e20-9aa6-edcd0212c87c} | |
- Home → Namespace Key: | |
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{f874310e-b6b7-47dc-bc84-b9e6b38f5903} | |
- OneDrive → Namespace Key: | |
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\OneDrive | |
How to Use It: | |
1. Run PowerShell as Administrator. | |
2. Copy & paste this script into PowerShell. | |
3. Select an option: | |
- 1 → Toggle Gallery | |
- 2 → Toggle Home | |
- 3 → Toggle OneDrive | |
- 4 → Remove All | |
- 5 → Exit | |
4. Explorer will restart automatically to apply changes. | |
=============================================================== | |
#> | |
# ===================== CONFIGURATION ===================== | |
# Define registry paths | |
$GalleryRegPath = "HKCU:\Software\Classes\CLSID\{e88865ea-0e1c-4e20-9aa6-edcd0212c87c}" | |
$HomeRegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{f874310e-b6b7-47dc-bc84-b9e6b38f5903}" | |
$OneDriveRegPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\OneDrive" | |
# ===================== FUNCTIONS ===================== | |
# Function to check if a registry key exists | |
function Test-RegPath { | |
param ($Path) | |
return Test-Path $Path | |
} | |
# Function to toggle Gallery in File Explorer | |
function Toggle-Gallery { | |
if (Test-RegPath $GalleryRegPath) { | |
Remove-Item -Path $GalleryRegPath -Recurse -Force | |
Write-Host "Gallery has been restored to File Explorer." | |
} else { | |
New-Item -Path $GalleryRegPath -Force | Out-Null | |
New-ItemProperty -Path $GalleryRegPath -Name "System.IsPinnedToNamespaceTree" -PropertyType DWord -Value 0 -Force | |
Write-Host "Gallery has been removed from File Explorer." | |
} | |
Refresh-Explorer | |
} | |
# Function to toggle removal/restoration of an Explorer entry (Home, OneDrive) | |
function Toggle-ExplorerEntry { | |
param ($RegPath, $RestoreValue, $RestoreName) | |
if (Test-RegPath $RegPath) { | |
Remove-Item -Path $RegPath -Recurse -Force | |
Write-Host "$RestoreName has been removed from File Explorer." | |
} else { | |
New-Item -Path $RegPath -Force | Out-Null | |
New-ItemProperty -Path $RegPath -Name "(Default)" -PropertyType String -Value $RestoreValue -Force | |
Write-Host "$RestoreName has been restored to File Explorer." | |
} | |
Refresh-Explorer | |
} | |
# Function to remove Gallery, Home, and OneDrive at once | |
function Remove-All { | |
if (-not (Test-RegPath $GalleryRegPath)) { | |
New-Item -Path $GalleryRegPath -Force | Out-Null | |
New-ItemProperty -Path $GalleryRegPath -Name "System.IsPinnedToNamespaceTree" -PropertyType DWord -Value 0 -Force | |
Write-Host "Gallery has been removed from File Explorer." | |
} else { | |
Write-Host "Gallery is already removed." | |
} | |
if (Test-RegPath $HomeRegPath) { | |
Remove-Item -Path $HomeRegPath -Recurse -Force | |
Write-Host "Home has been removed from File Explorer." | |
} else { | |
Write-Host "Home is already removed." | |
} | |
if (Test-RegPath $OneDriveRegPath) { | |
Remove-Item -Path $OneDriveRegPath -Recurse -Force | |
Write-Host "OneDrive has been removed from File Explorer." | |
} else { | |
Write-Host "OneDrive is already removed." | |
} | |
Refresh-Explorer | |
} | |
# Function to restart Explorer | |
function Refresh-Explorer { | |
Write-Host "Restarting Explorer..." | |
Stop-Process -Name explorer -Force | |
Start-Process explorer | |
} | |
# ===================== MENU SELECTION ===================== | |
# Force UTF-8 encoding for proper character display | |
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 | |
Write-Host "`nChoose an option:" | |
Write-Host "1 - Toggle Gallery" | |
Write-Host "2 - Toggle Home" | |
Write-Host "3 - Toggle OneDrive" | |
Write-Host "4 - Remove All" | |
Write-Host "5 - Exit" | |
$choice = Read-Host "Enter your choice (1-5)" | |
switch ($choice) { | |
"1" { Toggle-Gallery } | |
"2" { Toggle-ExplorerEntry -RegPath $HomeRegPath -RestoreValue "CLSID_MSGraphHomeFolder" -RestoreName "Home" } | |
"3" { Toggle-ExplorerEntry -RegPath $OneDriveRegPath -RestoreValue "OneDrive" -RestoreName "OneDrive" } | |
"4" { Remove-All } | |
"5" { Write-Host "Exiting..."; exit } | |
default { Write-Host "Invalid choice. Please run the script again." } | |
} | |
Write-Host "Changes applied successfully!" | |
# ===================== END OF SCRIPT ===================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment