Skip to content

Commit 5cdb425

Browse files
sudhirvermadgolovin
authored andcommitted
JBDS-4370 Windows uninstaller is not deleting "uninstaller" and "temp" and parent folders
1 parent a37ed81 commit 5cdb425

3 files changed

Lines changed: 90 additions & 99 deletions

File tree

browser/services/data.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,12 @@ class InstallerDataService {
7070
let uninstallerLocation = path.resolve(this.installRoot, 'uninstaller');
7171
Logger.info(`Data - Create uninstaller in ${uninstallerLocation}`);
7272
mkdirp.sync(uninstallerLocation);
73-
let uninstallerPs1 = path.resolve(path.join(__dirname, '..', '..', 'uninstaller', 'uninstall.ps1'));
74-
// write file content to uninstaller/uninstaller.ps1
75-
fsExtra.copy(uninstallerPs1, path.join(uninstallerLocation, 'uninstall.ps1'), (err) => {
73+
let uninstallerPs1 = path.resolve(path.join(__dirname, '..', '..', 'uninstaller'));
74+
fsExtra.copy(uninstallerPs1, uninstallerLocation, (err) => {
7675
if (err) {
7776
Logger.error('Data - ' + err);
7877
} else {
79-
Logger.info('Data - Copy ' + uninstallerPs1 + ' to ' + path.join(uninstallerLocation, 'uninstall.ps1') + ' SUCCESS');
78+
Logger.info('Data - Copy ' + uninstallerPs1 + ' to ' + uninstallerLocation + ' SUCCESS');
8079
}
8180
});
8281
}

uninstaller/uninstall-helper.ps1

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

uninstaller/uninstall.ps1

Lines changed: 3 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,5 @@
1-
#
21
$folder = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
32

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

Comments
 (0)