Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function New-ExplorerContextMenuEntry {
- param(
- $Identifier,
- $icon,
- $MenuText,
- $command,
- $Class
- )
- $OldLocation = Get-Location
- try {
- $Path = 'Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\{0}' -f $Class
- Set-Location -LiteralPath $Path -ErrorAction Stop
- } catch {
- Write-Host "Failed to enter known key: $_"
- return
- }
- New-Item -ItemType Container -Name 'shell' | Out-Null
- New-Item -ItemType Container -Name $Identifier -Path '.\shell' | Out-Null
- New-Item -ItemType Container -Name 'command' -Path ".\shell\$Identifier" | Out-Null
- New-ItemProperty -Name 'icon' -Value $Icon -PropertyType 'ExpandString' -Path ".\shell\$Identifier" | Out-Null
- New-ItemProperty -Name '(Default)' -Value $MenuText -PropertyType 'ExpandString' -Path ".\shell\$Identifier" | Out-Null
- New-ItemProperty -Name '(Default)' -Value $command -PropertyType 'ExpandString' -Path ".\shell\$Identifier\command" | Out-Null
- Set-Location $OldLocation
- }
Add Comment
Please, Sign In to add comment