Starting to think it is a use / messagebox conflict. Tested it long with the use commands alone last few days and it didnt gave problems (thats why I thought it was the homeshare problem). So I decided to use the whole script again and I had problems again. Now every time I disable the use * delete it keeps working good, then when I activate it again activate it again and it gives me the error again. If I disable the messagebox it also works good (this is all without rebooting).

Very strange...

Thanks for the help so far.