Windows API Error when running LaTeX over the web (MiKTeX installation) [closed]

I have installed MiKTeX 2.9 on a Windows Server 2003R2 with IIS. I have a CGI program that's internally running the command "latex filename" but this program is failing with an error message

initexmf.exe: Windows API error 5: Access is denied. initexmf.exe:
Data: C:\Documents and Settings\Default User\Local Settings\Application Data\MiKTeX
latex: The operation failed for some reason.
latex: Data: D:\Program Files\MiKTeX 2.9\miktex\bin\initexmf.exe


Running the same command from the command prompt as a local user works but not when I try to run it over the web. I have a second machine with an almost identical setup that has MiKTeX 2.6 installed. On this machine the same command works as expected over the web.

The installation directory is on a secondary drive (D-drive) under

D:\Program Files


So I tried to install MiKTeX on the C-drive under \Program Files and under C:\ and on the D-drive under D:\ but this didn't change anything. I've installed DebugView to identify the files that are accessed and the first file latex is tying to access is

D:\Program Files\MiKTeX 2.9\miktex\config\miktexstartup.ini


but this file doesn't exist. Obviously the permissions aren't set up properly for the user under which the CGI is run but I'm surprised that the MiKTeX installation didn't setup permissions properly.

Does anybody have an idea of what the problem could be?

-
It certainly might be the permissions, but it could also be the path. Defaulting to running initex is a classic behaviour when tex can't find anything. I wouldn't expect MiKTeX to set up any of that: it's a desktop application designed for the single user. –  Peter Flynn Feb 19 '12 at 0:23
As it stands, it's not really possible to give an answer here beyond 'probably a permission issue'. –  Joseph Wright Aug 6 '12 at 8:58