Mymod of Fred's script has a double safeguard: 
    ireturn = objShell.Run("NET STOP BOINC", 0, True)
    wscript.sleep (5000)
That 'True' halts execution until the 'NET' command returns (I'm only handling service mode at the moment, because that's what I use on my XP CUDA machines). Then there's a timed delay as well.
Can you emulate either of those in Perl?