debloat: deprovision preinstalled appx apps
This commit is contained in:
parent
05b43d8248
commit
5e4fee00fd
@ -3,3 +3,26 @@
|
||||
mnt="$(readlink -f "$1")"
|
||||
cd "$(dirname "$0")"
|
||||
../../reg_import.sh "$mnt" "$PWD/debloat.reg"
|
||||
|
||||
provisioned_apps="$(hivexregedit --export "$mnt/Windows/System32/config/SOFTWARE" 'Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications' --max-depth=2 --prefix="HKEY_LOCAL_MACHINE\SOFTWARE" |grep '^\[' | tail -n +2 | cut -d'\' -f9 | tr -d ']')"
|
||||
|
||||
{
|
||||
echo "Windows Registry Editor Version 5.00"
|
||||
echo
|
||||
echo '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned]'
|
||||
echo
|
||||
|
||||
for pkg in $provisioned_apps; do
|
||||
echo '[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications\'"$pkg"']'
|
||||
echo
|
||||
echo '[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Staged\'"$pkg"']'
|
||||
echo
|
||||
echo '[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Config\'"$pkg"']'
|
||||
echo
|
||||
# Adding to 'Deprovisioned' should prevent re-installing app upon windows upgrade
|
||||
echo '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\'"$pkg"']'
|
||||
echo
|
||||
rm -rf "$mnt/Program\ Files/WindowsApps/$pkg"
|
||||
done
|
||||
} > /tmp/deprovision.reg
|
||||
../../reg_import.sh "$mnt" "/tmp/deprovision.reg"
|
||||
|
@ -10,7 +10,7 @@ extract_prefix() {
|
||||
cat "$regfile" \
|
||||
| dos2unix \
|
||||
| grep -E '^[^;]' \
|
||||
| awk '/^Windows Re/ { print; want=1; next;} /^\['"$prefix_esc"'/ { want=1; print ""; print; next;} /^\[/ { want=0; } (want) { print;}' \
|
||||
| awk '/^Windows Re/ { print; want=1; next;} /^\[-?'"$prefix_esc"'/ { want=1; print ""; print; next;} /^\[/ { want=0; } (want) { print;}' \
|
||||
| sed -re 's/CurrentControlSet/ControlSet001/g'
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ def with_mounted(part):
|
||||
with ExitStack() as es:
|
||||
dir = Path(tempfile.mkdtemp(prefix=f"ntfs_{part.name}_"))
|
||||
es.callback(lambda: dir.rmdir())
|
||||
subprocess.run(['ntfs-3g', str(part), dir], check=True)
|
||||
subprocess.run(['ntfs-3g', '-o', 'remove_hiberfile', str(part), dir], check=True)
|
||||
es.callback(lambda: subprocess.run(['umount', dir]))
|
||||
yield dir
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user