Almost certainly you're doing something with COM which causes it to pop-up an invisible dialogue box.
This is the scourge of OLE automation and what makes it often unusable in back-end systems.
Bear in mind that under some Windows web servers (IIS), the user does not have a proper profile loaded so some things simply don't work as they would if you were "properly" logged on.
Maybe you can try to debug this by running IIS in its special debug mode where it can run as a normal user from the CLI (Yes, it is possible, read the docs).
Then again, maybe if you do that, it won't fail. This is frequently a problem.
Your best bet is to NOT USE OLE Automation in non-interactive applications. Most OLE automation things (MSword, Excel etc) do not handle errors in a way which is remotely suitable for non-internative use.
Mark