-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove.ps1
55 lines (45 loc) · 2.2 KB
/
remove.ps1
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<#
.SYNOPSIS
Removes the context menu entries created by setup.ps1 and deletes the symbolic link.
.DESCRIPTION
This script removes the context menu entries for .docx and .pdf files created by setup.ps1.
It also deletes the symbolic link created by setup.ps1 if it exists.
.NOTES
- The script requires elevated privileges (run as administrator).
.EXAMPLE
.\remove.ps1
#>
# Check for elevation
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host "Script is not running with elevated privileges. Restarting with elevation..."
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}
# Define the registry paths
$ContextMenuPathDocx = "HKCU:\Software\Classes\SystemFileAssociations\.docx\shell\CreateMarkdownAIPrompt"
$ContextMenuPathPdf = "HKCU:\Software\Classes\SystemFileAssociations\.pdf\shell\CreateMarkdownAIPrompt"
# Remove context menu entry for .docx files
if (Test-Path -Path $ContextMenuPathDocx) {
Remove-Item -Path $ContextMenuPathDocx -Recurse -Force
Write-Host "Removed context menu entry for .docx files." -ForegroundColor Green
} else {
Write-Host "Context menu entry for .docx files does not exist." -ForegroundColor Yellow
}
# Remove context menu entry for .pdf files
if (Test-Path -Path $ContextMenuPathPdf) {
Remove-Item -Path $ContextMenuPathPdf -Recurse -Force
Write-Host "Removed context menu entry for .pdf files." -ForegroundColor Green
} else {
Write-Host "Context menu entry for .pdf files does not exist." -ForegroundColor Yellow
}
# Determine the Program Files directory
$ProgramFilesDir = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::ProgramFiles)
$TargetDir = "$ProgramFilesDir\AI-Prompt-Workflow-Utilities"
# Remove the junction if it exists
if (Test-Path -Path $TargetDir) {
Remove-Item -Path $TargetDir -Recurse -Force
Write-Host "Removed symbolic link: $TargetDir" -ForegroundColor Green
} else {
Write-Host "Symbolic link does not exist: $TargetDir" -ForegroundColor Yellow
}
Write-Host "Removal script completed." -ForegroundColor Cyan