I think that's the issue isn't only the usefulness of the script. The script itself it's ugly :p
Actually, you should be getting first the recovery mode of the DB and after the shrink, you should set it again to the original mode. Also, there is a undocummented SP to LOOP over the DBs.
Identically to that, there is another to loop through the tables on the current DB:
Both of them have a LOT of useful parameters. Take a look at them.