-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOpenWithCompressed.ps1
More file actions
executable file
·31 lines (23 loc) · 2.12 KB
/
OpenWithCompressed.ps1
File metadata and controls
executable file
·31 lines (23 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Creates an "Open with aw-man" context menu item for common compressed formats.
param([switch]$Elevated)
function Test-Admin {
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
if ((Test-Admin) -eq $false) {
if ($elevated) {
# tried to elevate, did not work, aborting
} else {
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
}
exit
}
$executable = (Get-Command aw-man -ErrorAction Stop).Path
$command = """$executable"" ""%1"""
New-PSDrive -PSProvider registry -Root HKEY_CLASSES_ROOT -Name HKCR
$extensions = @(".zip", ".7z", ".rar", ".cbz", ".cbr")
ForEach ($ext in $extensions) {
$path = "HKCR:\SystemFileAssociations\$ext\Shell\Open with aw-man\command"
New-Item -Path $path -Force -Value $command -ErrorAction Stop
}
echo "Installed all context menu entries"