I think you're going to face an uphill struggle doing this in a web orientated language like PHP. Sure, php doesn't have to be used for the web and can do many things from a console but what you want to do is something very rare and therefore you'll not get much help with it.
If I'm honest, you're gonna be better off doing this in a windows programming language like c#, java, VB delphi etc.
My helpful sig has gone because a mod below the administrator gave me an infraction - despite the administrator personally agreeing to it.
If you need any php tips or tricks you can PM me.