Win32Exception on calling myProcess.start() method

  • Thread starter Thread starter Mitkip
  • Start date Start date
M

Mitkip

Hello,

Probably this question has been asked yet, but I can't find any answer
to my problem.
I have an ASP.NET application, which call a method which has to launch
a batch. To do it, I use an instance of the Process class. But when I
try to execute the start() method of this instance, it throws an
exception : " Win32Exception (0x80004005): Access is denied"

I think there is a way by using the System.Security.Permissions
namespace, but I can't find how to do it.

For information, when I change the identity of the pool which support
this application in IIS and set it to an administrator, it works ...
but I'd prefer not to do it ;)

many thanks
 
First, try to check the property NativeErrorCode from the
Win32Exception.

if it's equal to 5, it means the user from the web server (surely user
"ASPNET") does not have access to the executable file or something like
that. What exactly are you trying to execute?

Juan C. Olivares
www.juancri.com
 
Launching batch files, *.exe from asp/asp.net code is bad from the security
perspective.

What are you doing on that batch file? Can those actions be substituted with
server-side code?

Yes setting identity to an admin is not a good solution. However, you can
create a user that has required set of permissions, impersonate with it and
execute batch file.

Here are some links that will help you accomplish this:
(
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsent7/html/vxconImpersonation.asp )

( http://www.netomatix.com/ImpersonateUser.aspx )
 
Ok thank you guys,

My batch file execute some simple commands : a copy command followed by
a psexec call (to launch an .exe located on another server). Maybe
there is a way to do it without a batch, but i don't know how. If
someone has an idea, tell me

I am trying to use an impersonation with an admin, it works correctly
(I mean without exception), but the batch isn't really launched, seems
to be very strange. I will try to look at it

More ideas ?
 
Back
Top