The code is fine, works here on WinXP. Convert yahoo.gif to yahoo.bmp and try again.
Update: Also, take a look at Win32::Wallpaper and this article by Dave Roth - there's some code there to do it.
Also, I know I mentioned this in a PM, but Active Desktop doesn't play nice - make sure to get rid of it. Looks like your code is the same as Simple script to change win32 wallpaper
, which is two years old and hasn't had a complaint - so it's my guess that, as I originally suspected - it's not the code.