Published in Articles on by Michiel van Oosterhout ~ 4 min read

By default Windows 11 is configured to appeal to the masses, and comes with defaults that are geared more towards home use than professional use, let alone towards use as a secondary operating system in a Virtual Machine. The default configuration of Windows Explorer is a good example of this, with its focus on media consumption, cloud integration, and a level of simplification that is not necessarily a good fit for more professional use cases like, for example, software development.

Windows Explorer in Windows 11
Windows Explorer in Windows 11

Folder Options and virtual folders

Windows Explorer can be configured via the registry. Some registry values correspond to the options found in Windows Explorer's Folder Options dialog, for example Hide extensions for known file types. Other registry values apply more generally in Windows, for example values under the CLSID key that correspond to virtual folders.

# Registry key for Windows Explorer folder options
$path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"

# General > Open File Explorer to: This PC
Set-ItemProperty -Path $path -Name "LaunchTo" -Value 1

# View > Files and Folders
# Decrease space between items (compact view): On
Set-ItemProperty -Path $path -Name "UseCompactMode" -Value 1
# Hide extensions for known file types: Off
Set-ItemProperty -Path $path -Name "HideFileExt" -Value 0
# Show sync provider notifications: Off
Set-ItemProperty -Path $path -Name "ShowSyncProviderNotifications" -Value 0

# Hide Network from the navigation pane
$path = "HKCU:\Software\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}"
$key = New-Item -Force -ItemType "Directory" -Path $path
$value = New-ItemProperty -Name "System.IsPinnedToNameSpaceTree" -Path $path -PropertyType "DWord" -Value 0

# Restart Windows Explorer
Stop-Process -Name "explorer"

Quick access

You may also want to programmatically unpin items from Quick access. These items are stored in a Jump List file named f01b4d95cf55d32a.automaticDestinations-ms in $Env:APPDATA\Microsoft\Windows\Recent\AutomaticDestinations. Unfortunately PowerShell lacks the ability to work with this type of file.

Quick access is also available as a Windows Shell namespace. So the items in Quick access can directly be interacted with from a Windows PowerShell script via the Windows Shell object Shell.

This Windows PowerShell script gets the Quick access namespace (a Folder object), and iterates over the items in it (a collection of FolderItems), and executes a specific action (unpinfromhome) that is known to be supported by items in this namespace. This removes all pinned items from Quick access.

# Create the Shell's automation object
$shell = New-Object -ComObject "Shell.Application"

# Get a reference to the Quick access namespace
$quickAccess = $shell.NameSpace("shell:::{679F85CB-0220-4080-B29B-5540CC05AAB6}")

# Remove all the items from the Quick access namespace
$quickAccess.Items() | ForEach-Object {
    $name = $_.Name

    Write-Host "Unpinning [$name] from Quick access..." -NoNewline
    $_.InvokeVerb("unpinfromhome")
    Write-Host " OK"
}

# Define items to be added to the Quick access namespace
$items = @(
    @{ Path = "$Env:USERPROFILE"; DisplayName = "~" }
    @{ Path = "$Env:USERPROFILE\Desktop"; DisplayName = "Desktop" }
    @{ Path = "$Env:USERPROFILE\Downloads"; DisplayName = "Downloads" }
)

# Add each item to the Quick access namespace
$items | ForEach-Object {
    $displayName = $_.DisplayName

    Write-Host "Pinning [$displayName] to Quick access..." -NoNewline
    $shell.NameSpace($_.Path).Self.InvokeVerb("pintohome")
    Write-Host " OK"
}

The script then pins a select set of locations to Quick access by invoking another action (pintohome) on the namespace corresponding to each of those locations.

Personal folders

This Windows PowerShell script removes some of the personal folders (directories in $Env:USERPROFILE).

# List of personal folders to be removed
$folders = @(
    "Contacts"
    "Links"
    "Music"
    "Pictures"
    "Saved Games"
    "Videos"
)

# Delete each folder
$folders | ForEach-Object {
    $path = "$Env:USERPROFILE\$_"
    if (Test-Path $path)
    {
        Write-Host "Removing [$_]..." -NoNewline
        Remove-Item -Force -Path $path -Recurse
        Write-Host " OK"
    }
}

The list of personal folders to remove is just a sugestion of course, and can be easily changed.

Summary

Windows Explorer provides a wide variety of objects that can be used manage your files and directories. Depending on the type of object, automating the configuration requires a specific approach. This article showed 3 different approaches: one registry-based, one based on Windows Shell automation, and one based on simple file system operations.