Very old topic, but this was a bug fixed with SQL 2008 R2 CU11 / SQL Server 2012 SP 1 Cumulative Update 7 (see https://social.msdn.microsoft.com/Forums/en-US/e6b1a3c6-9405-482d-b4ef-5c788f14cd8f/xpdeletefile-extremely-slow-on-a-server-waitinfo-preemptiveosgetprocaddress?forum=sqldatabaseengine).
Regardless of this fix I'm very thankful for the script above because we have an SQL2008 server without SP3 (for compatibility reasons) where could use it.