- Local time
- 9:02 AM
- Posts
- 3,028
- OS
- Windows 11 Pro
PowerShell script that will launch the Windows 10 Style shell of Explorer and will Launch to either "This PC" or "Home" depending on what you have set in Folder Options as your default. I have compiled an exe using ps2exe, but it may initially trigger Windows Defender. You can either compile it yourself using the code below, or simply unblock the exe in Defender (tried base64 encoding to avoid the block but it wouldn't take. ( @garlin or @pseymour i'm all ears if you can tell me a better method) (@LesFerch , not sure if you want to add this into your OldExplorer or not) I have attached a .bat that will run the PowerShell script as well.
Code:
# Create Shell.Application COM object
PowerShell.exe -WindowStyle hidden {$Shell_Application = New-Object -ComObject Shell.Application
# Define constants
$ControlPanel = "::{26EE0668-A00A-44D7-9371-BEB064C98683}" # Control Panel (always Category view)
$LaunchTo = @(
"{20D04FE0-3AEA-1069-A2D8-08002B30309D}", # This PC
"{679f85cb-0220-4080-b29b-5540cc05aab6}" # Home
)
# Read registry key for launch destination
try {
$k = (Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "LaunchTo" -ErrorAction Stop).LaunchTo
} catch {
$k = 1 # default - This PC
}
# Ensure $k is within array bounds
if ($k -lt 1 -or $k -gt $LaunchTo.Count) {
$k = 1
}
# Open Control Panel
$ProgressPreference.SilentlyContinue
$Shell_Application.Open($ControlPanel)
# Wait and navigate
$start_time = Get-Date
$timeout = New-TimeSpan -Seconds 1
while ((Get-Date) - $start_time -lt $timeout) {
foreach ($window in $Shell_Application.Windows()) {
if ($window.Document.Folder.Self.Path -eq $ControlPanel) {
$window.Navigate("shell:::" + $LaunchTo[$k - 1])
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.SendKeys]::SendWait("({ESC})")
exit
}
}
Start-Sleep -Milliseconds 10
}
}
Attachments
My Computer
System One
-
- OS
- Windows 11 Pro