-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathUnInstallScript.ps1
More file actions
76 lines (61 loc) · 2.62 KB
/
UnInstallScript.ps1
File metadata and controls
76 lines (61 loc) · 2.62 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# elevation handled by the calling .bat file to allow script execution policy override
<#
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
}
#>
# registry vars
$iCloneKeyPath = "HKLM:\SOFTWARE\Reallusion\iClone\8.0"
$charCreatorKeyPath = "HKLM:\SOFTWARE\Reallusion\Character Creator\4.0"
$charCreatorFiveKeyPath = "HKLM:\SOFTWARE\Reallusion\Character Creator\5.0"
$valueName = "Install Path"
# path vars
$subFolder = "OpenPlugin"
# script vars
$scriptFolder = $PSScriptRoot
#$scriptFolderName = Split-Path -Path $scriptFolder -Leaf
$scriptFolderName = "Blender Pipeline Plugin"
function Remove-Junction($keyPath){
$keyExists = Test-Path -Path $keyPath
if($keyExists){
Write-Host "`n Found $keyPath in the registry."
# check if the entry "Install Path" is present within the key
$entryExists = Get-ItemProperty -Path $keyPath -Name $valueName -ErrorAction SilentlyContinue
if ($entryExists){
$entryValue = Get-ItemPropertyValue -Path $keyPath -Name $valueName
# find directory junction
$junctionPath = "$entryValue\$subFolder\$scriptFolderName"
$junctionExists = Test-Path -Path $junctionPath
if($junctionExists){
cmd /c rmdir /s /q $junctionPath
Write-Host "`n Folder/Link $junctionPath deleted."
}else{
Write-Host "`n Expected folder link $junctionPath is absent."
}
}else{
Write-Host "`n Cannot find $valueName in the registry key... skipping."
}
}else{
Write-Host "`n Cannot find $keyPath in the registry... skipping."
}
}
Write-Host "`n*******************************************************************"
Write-Host "`n This script will remove links created by the installation script."
Write-Host "`n*******************************************************************"
$keyPaths = @($iCloneKeyPath, $charCreatorKeyPath, $charCreatorFiveKeyPath)
foreach ($entry in $keyPaths){
Write-Host "`n`n Processing $entry ..."
Remove-Junction($entry)
}
Write-Host "`n`n Process Complete - Press any key to exit...`n"
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")