Remove crapwares for WAPT
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
3.8 KiB

# -*- 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'),
'metro:Microsoft.XboxGameCallableUI',
'metro:Microsoft.MSPaint',
'metro:Microsoft.SkypeApp',
'metro:Microsoft.XboxGameOverlay',
'metro:Microsoft.Whiteboard',
'metro:Microsoft.Microsoft3DViewer',
'metro:Microsoft.XboxIdentityProvider',
'metro:Microsoft.Xbox.TCUI',
'metro:Microsoft.MicrosoftStickyNotes',
'metro:Microsoft.ZuneMusic',
'metro:Microsoft.ZuneVideo',
'metro:Microsoft.WindowsMaps',
'metro:Microsoft.WindowsMaps',
'metro:Microsoft.BingWeather',
'metro:Microsoft.MicrosoftSolitaireCollection',
'metro:Microsoft.OneConnect',
'metro:Microsoft.WindowsFeedbackHub',
'metro:Microsoft.XboxApp',
'metro:Microsoft.XboxSpeechToTextOverlay',
'metro:Microsoft.Windows.ParentalControls',
'metro:Microsoft.Windows.Cortana'
]
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
if isinstance(crapware,(unicode,str)) and crapware.startswith('metro:') and windows_version() > Version('10'):
print('Processing removal of %s '% title)
remove_metroapp(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)