Monday, February 22, 2010

"System.ComponentModel.Win32Exception: Access is denied" Error message when attempting to run command line program from ASP.NET

See this post for information on how to run command line programs from ASP.NET. The solution to the error message is to add NTFS read permissions for the website user to %windir%\system32\cmd.exe.

3 comments:

  1. DUDE! As, in, that totally fixed my problem, thank you very much! :-)
    ReplyDelete
  2. I'm confused. Where in that link does it talk about NTFS read permissions? The fix for that SO question was adding "/c dir" to the arguments.Can you be more specific about how you got around this?
    ReplyDelete
  3. You're right, it wasn't his answer, but the answer for me was posted as a possible answer to that Q on SO:

    "Most likely your problem is with the permissions. The user under which ASP.NET process runs is with very limited rights.

    So, either you have to set the proper permissions for that user, or run ASP.NET under some other user."

    So if my ASP.NET code is trying to do something via command line (which implicitly calls cmd.exe), my ASP.NET user better have permission to call cmd.exe.
    ReplyDelete