From within a stored procedure in master try something like this:
DECLARE @dbname sysname
DECLARE @cmd varchar(2000)
-- some magic happens so that @dbname takes on the name of a database <s>
SET @cmd = 'USE ' + @dbname + CHAR(13) + CHAR(10)
SET @cmd = @cmd + 'EXECUTE master..sp_cleanup'
Catching errors will be the difficult part. In the beginning I'd just write them to the log with xp_logevent.
-Mike