A couple of things to consider:
- Does the program have the desired result when run as a CGI script?
- Do other scripts run on the server as cgi or exe?
- What output do you get from the script when executed from the command line?
My guess is that you have a problem with printing the correct header, but it could still be a server issue. If you still can't figure it out, post some example a code and output - someone should be able to find you issue quickly if it is a coding problem.