Solved Windows 10 Explorer (Ribbon) .exe - *Abides by Folder Options Open Parameter*


dacrone

Well-known member
Pro User
VIP
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
Most security products will block executable files created by ps2exe or bat2exe tools. Their file output format is easy to spot, and banned on general principle because of overuse by script kiddies.
 

My Computer

System One

  • OS
    Windows 7
Most security products will block executable files created by ps2exe or bat2exe tools. Their file output format is easy to spot, and banned on general principle because of overuse by script kiddies.
when i compile python to exe, i just edit the .py to encode in base64 before compiling and it doesn't trip defender. if i compile the .py without encoding, the output .exe does trip defender. i assumed if i could get the ps encoded to base64 correctly and then compile it, i would get the same results as with .py
 

My Computer

System One

  • OS
    Windows 11 Pro
I've read Defender real-time scanning can wait until a program runs, before attempting to scan its memory for plaintext that looks like a script. Which is why most malware use some encoding/encryption to elude inspections, because you're hiding the execution inside a script block.
 

My Computer

System One

  • OS
    Windows 7
I've read Defender real-time scanning can wait until a program runs, before attempting to scan its memory for plaintext that looks like a script. Which is why most malware use some encoding/encryption to elude inspections, because you're hiding the execution inside a script block.
so with the powershell script i posted, how would i properly convert it to base64 (like inside ISE to test)? python is easy because its 2 lines above the script and 4 lines below it.. i just saved a template and paste py scripts in that. if i know how to do it properly with PS i can make a template for that as well. i tried a handful of things i read online but couldn't get it to function
 

My Computer

System One

  • OS
    Windows 11 Pro
Why are you converting it to exe at all though?
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
Nothing wrong with the learning part, but the folks can just right-click, Run with PowerShell.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
yeah i'm tracking. or double click the .bat. or run either from terminal. i'll just go with 'because i want to' lol. it has work. got python working and i know very little python
 

My Computer

System One

  • OS
    Windows 11 Pro

Latest Support Threads

Back
Top Bottom