Well, don't know why you get all those $name from a text file cuz you never use them. All your reg mods are done to the local machine. Don't you want to modify the remote machines?

Should it not be:
$nul=writevalue("\\"+$name+"\HKLM\SOFTWARE\Classes\Excel.Chart.5","editflags","00 00 01 00","REG_SZ")

Also, the code is overly optimistic. I don't think it was meant as a complete solution on a silver platter, but rather as a proof of concept. You should check if the machine is turned on, if the reg write was successful, etc.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.