Uninstall Package script

set pkgsList to paragraphs of (do shell script "pkgutil --pkgs")

set pkgToDelete to item 1 of (choose from list pkgsList with prompt "Choose package to delete")
set pkgToDelete to quoted form of pkgToDelete

display dialog "ARE YOU SURE TO DELETE THIS PACKAGE ?" buttons {"CANCEL", "YES"} ¬
	default button "CANCEL"

if button returned of result is "YES" then
	do shell script "pkgutil --forget " & pkgToDelete with administrator privileges
end if

NOTE: Be careful: the first time you run the script, the compiler remembers the password, so when you re-run script, the packages are deleted immediately, without asking for a password again.