parent
905a08ab5e
commit
0cc4511d63
3 changed files with 428 additions and 0 deletions
@ -0,0 +1,32 @@ |
||||
package : fws-remove-crapwares |
||||
version : 1 |
||||
architecture : all |
||||
section : base |
||||
priority : normal |
||||
maintainer : Daniel Berteaud <daniel@firewall-services.com> |
||||
description : Uninstall unwanted softwares |
||||
depends : |
||||
conflicts : |
||||
maturity : DEV |
||||
locale : |
||||
target_os : windows |
||||
min_os_version : 5 |
||||
max_os_version : |
||||
min_wapt_version : 1.5 |
||||
sources : |
||||
installed_size : |
||||
impacted_process : |
||||
description_fr : |
||||
description_pl : |
||||
description_de : |
||||
description_es : |
||||
audit_schedule : |
||||
editor : |
||||
keywords : |
||||
licence : |
||||
homepage : https://www.firewall-services.com/ |
||||
package_uuid : |
||||
signer : Daniel Berteaud |
||||
signer_fingerprint: |
||||
signature_date : |
||||
signed_attributes : |
@ -0,0 +1,101 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from setuphelpers import * |
||||
import re |
||||
|
||||
uninstallkey = [] |
||||
|
||||
# re: regular match for soft name |
||||
# key: exact match for uninstallkey |
||||
# run: provide direct command for uninstall |
||||
# metro: remove a metro app with powershell |
||||
# str or list : keywords in key and/or name |
||||
|
||||
# tuple : (search,process_to_kill,title) |
||||
|
||||
# look to http://www.shouldiremoveit.com/oems-bloatware.aspx for information about bloatwares |
||||
|
||||
crapwares = [ |
||||
're:ask toolbar', |
||||
('key:{7DB9F1E5-9ACB-410D-A7DC-7A3D023CE045}','welcome.exe','Dell Getting Started Guide'), |
||||
'key:MozillaMaintenanceService', |
||||
'metro:Microsoft.XboxGameCallableUI', |
||||
'metro:Microsoft.MSPaint', |
||||
'metro:Microsoft.SkypeApp', |
||||
'metro:Microsoft.XboxGameOverlay', |
||||
'metro:Microsoft.Whiteboard', |
||||
'metro:Microsoft.Microsoft3DViewer', |
||||
'metro:Microsoft.XboxIdentityProvider', |
||||
'metro:Microsoft.MicrosoftStickyNotes', |
||||
'metro:Microsoft.ZuneMusic', |
||||
'metro:Microsoft.WindowsMaps', |
||||
'metro:Microsoft.WindowsMaps' |
||||
] |
||||
|
||||
def find_soft_re(softs,pattern): |
||||
return [s for s in softs if pattern.findall(s['name'])] |
||||
|
||||
def find_soft_keywords(softs,keywords): |
||||
def check_words(target,words): |
||||
mywords = target.lower() |
||||
result = not words or mywords |
||||
for w in words: |
||||
result = result and w in mywords |
||||
return result |
||||
|
||||
return [s for s in softs if check_words(s['key'] + ' '+ s['name'],keywords)] |
||||
|
||||
def install(): |
||||
|
||||
all_softs = installed_softwares() |
||||
|
||||
for crapware in crapwares: |
||||
# split if processes to kill is supplied too |
||||
if isinstance(crapware,tuple): |
||||
if len(crapware) == 3: |
||||
(crapware,to_kill,title) = crapware |
||||
elif len(crapware) == 2: |
||||
(crapware,to_kill) = crapware |
||||
title = crapware |
||||
else: |
||||
to_kill = None |
||||
title = crapware |
||||
|
||||
run = None |
||||
# metro app must be removed with powershell |
||||
if isinstance(crapware,(unicode,str)) and crapware.startswith('metro:') and windows_version() > Version('10'): |
||||
print('Removing %s (metro app)' % crapware[6:]) |
||||
run_powershell(r'Get-AppxPackage -AllUsers | where-object {$_.name -like "%s"} | Remove-AppxPackage' % crapware[6:]) |
||||
elif isinstance(crapware,re._pattern_type): |
||||
uninstall_entries = find_soft_re(all_softs,crapware) |
||||
elif isinstance(crapware,(unicode,str)) and crapware.startswith('re:'): |
||||
uninstall_entries = find_soft_re(all_softs,re.compile(crapware[3:],re.IGNORECASE)) |
||||
elif isinstance(crapware,(unicode,str)) and crapware.startswith('key:'): |
||||
uninstall_entries = [s for s in all_softs if s['key'] == crapware[4:]] |
||||
elif isinstance(crapware,(unicode,str)) and crapware.startswith('run:'): |
||||
uninstall_entries = [] |
||||
run = crapware[4:] |
||||
# check if command exists |
||||
|
||||
|
||||
else: |
||||
if isinstance(crapware,(str,unicode)): |
||||
mykeywords = crapware.lower().split() |
||||
else: |
||||
mykeywords = [ ensure_unicode(k).lower() for k in crapware ] |
||||
uninstall_entries = find_soft_keywords(all_softs,mykeywords) |
||||
|
||||
if uninstall_entries or run: |
||||
print('Processing removal of %s '%(title,)) |
||||
if to_kill: |
||||
print(' Killing processes %s' % (to_kill,)) |
||||
killalltasks(to_kill) |
||||
|
||||
for uninstall in uninstall_entries: |
||||
cmd = WAPT.uninstall_cmd(uninstall['key']) |
||||
print(u' Uninstalling %s' % (uninstall['name'],)) |
||||
run_notfatal(cmd) |
||||
|
||||
if run: |
||||
print(u' Launching %s' % (run,)) |
||||
run_notfatal(run) |
||||
|
Loading…
Reference in new issue