|
1 | | -# |
2 | 1 | $folder = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition |
3 | 2 |
|
4 | | -$vboxInstalled = Test-Path $folder'\..\virtualbox' |
5 | | -$vagrantInstalled = Test-Path $folder'\..\vagrant' |
6 | | -$openjdkInstalled = Test-Path $folder'\..\jdk8' |
7 | | - |
8 | | -$devstudiofolder = $folder + '\..\developer-studio'; |
9 | | -$devstudioInstalled = Test-Path $devstudiofolder; |
10 | | - |
11 | | -echo 'Uninstalling Red Hat Development Suite' |
12 | | - |
13 | | -if ( $vboxInstalled ) { |
14 | | - echo 'Removing VirtualBox' |
15 | | - $vbox = Get-WmiObject Win32_Product | where {$_.Name -like '*VirtualBox*'} |
16 | | - msiexec /x $vbox.IdentifyingNumber /qb /norestart | Out-Null |
17 | | - echo 'DONE' |
18 | | - |
19 | | - $vboxVmsExists = Test-Path $env:USERPROFILE'\VirtualBox VMs' |
20 | | - if($vboxVmsExists) { |
21 | | - echo 'Removing VirtualBox VMs folder' |
22 | | - Remove-Item -Recurse $env:USERPROFILE'\VirtualBox VMs' |
23 | | - echo 'DONE' |
24 | | - } |
25 | | -} |
26 | | - |
27 | | -if( $vagrantInstalled ) { |
28 | | - echo 'Removing Vagrant' |
29 | | - $vagrant = Get-WmiObject Win32_Product | where {$_.Name -like '*Vagrant*'} |
30 | | - msiexec /x $vagrant.IdentifyingNumber /qb /norestart | Out-Null |
31 | | - echo 'DONE' |
32 | | - |
33 | | - $vagrantDExists = Test-Path $env:USERPROFILE'\.vagrant.d' |
34 | | - if($vagrantDExists){ |
35 | | - echo 'Removing vagrant.d folder' |
36 | | - Remove-Item -Recurse $env:USERPROFILE'\.vagrant.d' |
37 | | - echo 'DONE' |
38 | | - } |
39 | | -} |
40 | | - |
41 | | -if ( $openJdkInstalled ) { |
42 | | - echo 'Removing Red Hat OpenJDK' |
43 | | - $vbox = Get-WmiObject Win32_Product | where {$_.Name -like '*OpenJDK*'} |
44 | | - msiexec /x $vbox.IdentifyingNumber /qb /norestart | Out-Null |
45 | | - echo 'DONE' |
46 | | -} |
47 | | - |
48 | | -if ($devstudioInstalled) { |
49 | | - echo 'Removing shortcuts' |
50 | | - [xml]$installConfig = Get-Content $devstudiofolder'\InstallConfigRecord.xml'; |
51 | | - $shortcuts = $installConfig.AutomatedInstallation.'com.izforge.izpack.panels.ShortcutPanel'.shortcut.name; |
52 | | - |
53 | | - $desktop = [Environment]::GetFolderPath("Desktop"); |
54 | | - $programs = [Environment]::GetFolderPath("Programs"); |
55 | | - |
56 | | - $shortcuts | % { |
57 | | - if ((Test-Path $desktop'\'$_'.lnk')) { |
58 | | - Remove-Item $desktop'\'$_'.lnk'; |
59 | | - } elseif (Test-Path $programs'\'$_) { |
60 | | - Remove-Item $programs'\'$_ -Recurse; |
61 | | - } |
62 | | - } |
63 | | - echo 'DONE' |
64 | | -} |
65 | | - |
66 | | -echo 'Removing installation folder' |
67 | | -Cmd /C "rmdir /S /Q $folder\.." | Out-Null |
68 | | - |
69 | | -$subfolders = Get-ChildItem "$folder\.." -Directory -ErrorAction SilentlyContinue | ForEach-Object { $_.FullName } |
70 | | - |
71 | | -if ($subfolders.Length -gt 0) { |
72 | | - New-Item "$folder\..\temp" -type Directory -Force | Out-Null |
73 | | - foreach ($item in $subfolders) { |
74 | | - robocopy $folder\..\temp $item /purge | Out-Null |
75 | | - } |
76 | | - Remove-Item "$folder\.." -Recurse -Force |
77 | | -} |
78 | | -echo 'DONE' |
79 | | - |
80 | | -echo 'Removing path entries' |
81 | | -[string[]] $pathFolders = [Environment]::GetEnvironmentVariable("Path", "User") -Split ';' |
82 | | -[Collections.ArrayList] $folderList = New-Object Collections.Arraylist |
83 | | - |
84 | | -$targetFolder = [System.IO.Path]::GetFullPath((Join-Path ($folder) '..')) |
85 | | - |
86 | | -$pathFolders | foreach { |
87 | | - If (-Not ($_ -like "$targetFolder*")) { |
88 | | - $folderList.Add($_) | Out-Null |
89 | | - } |
90 | | -} |
91 | | - |
92 | | -[string] $delimitedFolders = $folderList -Join ';' |
93 | | -[Environment]::SetEnvironmentVariable("Path", $delimitedFolders, "User") |
94 | | - |
95 | | -echo 'DONE' |
96 | | -Write-Host "Press any key to exit" |
97 | | -$key = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") |
| 3 | +Copy-Item ./uninstall-helper.ps1 $env:TEMP/uninstall-helper.ps1 |
| 4 | +cd ../.. |
| 5 | +Start-Process powershell.exe -ArgumentList $env:TEMP\uninstall-helper.ps1, $folder |
0 commit comments