Guest User

Untitled

a guest
Dec 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. function New-ExplorerContextMenuEntry {
  2. param(
  3. $Identifier,
  4. $icon,
  5. $MenuText,
  6. $command,
  7. $Class
  8. )
  9.  
  10. $OldLocation = Get-Location
  11. try {
  12. $Path = 'Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\{0}' -f $Class
  13. Set-Location -LiteralPath $Path -ErrorAction Stop
  14. } catch {
  15. Write-Host "Failed to enter known key: $_"
  16. return
  17. }
  18. New-Item -ItemType Container -Name 'shell' | Out-Null
  19. New-Item -ItemType Container -Name $Identifier -Path '.\shell' | Out-Null
  20. New-Item -ItemType Container -Name 'command' -Path ".\shell\$Identifier" | Out-Null
  21.  
  22. New-ItemProperty -Name 'icon' -Value $Icon -PropertyType 'ExpandString' -Path ".\shell\$Identifier" | Out-Null
  23. New-ItemProperty -Name '(Default)' -Value $MenuText -PropertyType 'ExpandString' -Path ".\shell\$Identifier" | Out-Null
  24. New-ItemProperty -Name '(Default)' -Value $command -PropertyType 'ExpandString' -Path ".\shell\$Identifier\command" | Out-Null
  25.  
  26. Set-Location $OldLocation
  27. }
Add Comment
Please, Sign In to add comment