<#
Setup.ps1
Adobe Digital Editions
https://forums.adobe.com/thread/1976740
Place insaller in .\setup directory
Sailer, Adam
2018.05.10
#>
$invoke = split-path -path $myInvocation.MyCommand.Path -parent
$os = gwmi win32_OperatingSystem
$proc = gwmi win32_Processor
$whatIf = $false
Function KillApps
{
write-host "`n`n@@ KillApps" -fore magenta
$array = get-process | ? { $_.Path -imatch '\\ade_|\\adobe digital editions' }
$array; $array | stop-process -force
dir $env:Temp | remove-item -recurse -force -ea silentlyContinue
}
Function Uninstall
{
param([string]$inp)
write-host "`n`n@@ Uninstall" -fore magenta
if (!$inp) { return }
$paths = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
,'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
) | ? { test-path $_ }
dir $paths | gp | ? { $_.DisplayName -imatch $inp } | % { $item = $_
$item.UninstallString | ? { $_ } | % {
$app = $_; $options = '/s'
write-host "Uninstall : $($item.DisplayName)"
write-host $options -fore darkGray
if (!$whatIf) {
$process = start-process -filePath $app -argumentList $options -passThru; $process | wait-process
$process.ExitCode
$process.ExitCode | ? { $_ -ne 0 } | % { exit $_ }
}
}
}
}
Function Setup
{
write-host "`n`n@@ Setup" -fore magenta
dir $invoke\setup -recurse -include *.exe | % { $app = $_
$keys = @('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall')
if ($proc.AddressWidth -eq 64) { $keys += 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall' }
$options = '/s NSS=0'
write-host "Setup : $($app.Name)"
write-host $options -fore darkGray
if (!$whatIf) {
try {
$keys | % { new-item -path $_ -name 'N360' -force -verbose }
$env:see_mask_nozonechecks = 1
$process = start-process -filePath $app -argumentList $options -passThru; $process | wait-process
remove-item env:\see_mask_nozonechecks
$process.ExitCode
$process.ExitCode | ? { $_ -ne 0 } | % { exit $_ }
}
catch {
}
finally {
$keys | % { remove-item -path "$_\N360" -force -verbose }
}
}
}
}
#
#
Clear
KillApps
Uninstall 'adobe digital editions'
Setup
exit 0
Comments