Skip to content

Instantly share code, notes, and snippets.

@secdev02
Created November 29, 2025 17:18
Show Gist options
  • Select an option

  • Save secdev02/7ea50aa10510d354af73d34d1af6a5ad to your computer and use it in GitHub Desktop.

Select an option

Save secdev02/7ea50aa10510d354af73d34d1af6a5ad to your computer and use it in GitHub Desktop.
Custom URI / Schemes

Creates a scheme called helper://

Then does things.

Normal users can register and call their own schemes.

Also above I show how to enumerate schemes...

### --- PART 1: LIST ALL REGISTERED URL SCHEMES --- ###
Write-Host "Registered URL Schemes (from HKCU + HKLM):`n------------------------"
# Per-user schemes
$schemesUser = Get-ChildItem "HKCU:\Software\Classes" |
Where-Object {
($_ | Get-ItemProperty -ErrorAction SilentlyContinue)."(Default)" -match "URL:" `
-and (Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue)."URL Protocol" -ne $null
}
# System-wide schemes
$schemesSystem = Get-ChildItem "HKLM:\Software\Classes" |
Where-Object {
($_ | Get-ItemProperty -ErrorAction SilentlyContinue)."(Default)" -match "URL:" `
-and (Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue)."URL Protocol" -ne $null
}
$schemes = $schemesUser + $schemesSystem
foreach ($s in $schemes) {
Write-Host $s.PSChildName
}
Write-Host "`nTotal Schemes Found: $($schemes.Count)"
### --- PART 2: REGISTER helper:// PROTOCOL (Per-User) --- ###
$protocolRoot = "HKCU:\Software\Classes\helper"
# Path to your application EXE (modify to your real path)
# Create some sample code to practice signing on
Add-Type -TypeDefinition @'
public class Foo {
public static void Main(string[] args) {
System.Console.WriteLine("Hello, Darkness My Old Friend!");
System.Console.ReadKey();
}
}
'@ -OutputAssembly C:\Tools\HelloDarknessMyOldFriend.exe
$AppPath = "C:\Tools\HelloDarknessMyOldFriend.exe"
# URL argument "%1" gets passed to the EXE
$Arguments = "`"%1`""
# Validate the EXE exists
if (-not (Test-Path $AppPath)) {
Write-Host "ERROR: Application not found at $AppPath" -ForegroundColor Red
return
}
# Create protocol root and keys
New-Item -Path $protocolRoot -Force | Out-Null
Set-ItemProperty -Path $protocolRoot -Name "(Default)" -Value "URL:Helper Protocol"
Set-ItemProperty -Path $protocolRoot -Name "URL Protocol" -Value ""
# Create open command structure
New-Item -Path "$protocolRoot\shell" -Force | Out-Null
New-Item -Path "$protocolRoot\shell\open" -Force | Out-Null
New-Item -Path "$protocolRoot\shell\open\command" -Force | Out-Null
# Final command line
$command = "`"$AppPath`" $Arguments"
Set-ItemProperty -Path "$protocolRoot\shell\open\command" -Name "(Default)" -Value $command
Write-Host "`nRegistered protocol 'helper://' successfully!" -ForegroundColor Green
Write-Host "Command used: $command"
Start-Process "helper://test"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment