Running command line tool from web application

G

Guest

I have a command line tool that I would like to run from my .NET web
application using System.Diagnostics.ProcessStartInfo. I run cmd.exe with
this and then pass the command to run the tool as an argument to the process.
When I try this from a Windows application it works fine, however, when I do
this from my web application I get errors.

Both applications are running under the same users so am not sure if it is a
permissions problem.

If anyone has an ideas it would be most appreciated. THANKS!
 
G

Guest

Mandy,
By default ASP.NET applications are hosted by a process called
aspnet_wp.exe. This process runs under the ASPNET user account. This user has
only limited privilages. To run your appliation under a different user you
have to enable impersonation.
Add this to your web.config file in <configuration> section.
<identity impersonate="true" />. and turn off anonymous access to the page
in IIS.
This will run your application under the user who accesses the page. You can
also give a default user
<identity impersonate="true" userName="contoso\Jane" password="pass"/>

http://msdn.microsoft.com/library/d...-us/cpguide/html/cpconaspnetimpersonation.asp

hope this helps

Rak
 
K

Kevin Spencer

Hi Mandy,

It isn't necessary to start the cmd.exe utility. Just start the process you
want to start. I'm not sure if that is related to your errors, as you didn't
mention what the errors ARE. However, I have also never tried to run an
executable by calling cmd.exe. That could be the cause of your problem.

Let me illustrate:

Start Process cmd.exe with argument to run some other exe
cmd.exe starts
cmd.exe starts the other exe

Versus
Start process of desired exe

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
G

Guest

Thanks for your post but I already have impersonation enabled to the same
user as the one that the Windows application runs as, and still the tool will
not run... This user has full control over the tool and the directory it
resides in.
 
G

Guest

Thanks for your post, but I already have impersonation enabled to a user that
has full control access to the tool and the directory it resides in. It is
the same user that the Windows application (that can run the tool fine) runs
under...
 
G

Guest

I changed my code to what you suggested and I still have the same problem.
The errors I get state the the application could not be run. I'm pretty sure
I am calling it correcting as when I copy the code into a Windows
application, the tool runs perfectly. If you have anymore suggestions,
please let me know.

Thanks for you help!
 
K

Kevin Spencer

Well, Mandy, I still have one suggestion left over from my previous post:
What exactly is the exception message you're getting?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
C

Chris Dickens

I am also running into a very similar problem attempting to run a
command-line utility which comes with Windows 2003 called WINPOP.EXE which
creates and modifies POP3 mailboxes on the host server. I always get an
Access is Denied error when attampting to run it via either method listed.

Hopefully someone can provide some insight on this issue. (Or at least some
tips on debugging/locating what exactly the process is being denied access
to?) I have done a number of things like setting Everyone Full Control
access to the entire server's hard drive as well as all of the registry
hives. I can only assume that .net Access Policy (CAS) is somehow involved,
but I'm not sure how to circumvent this yet.

BTW: I have also tried to impersonate the user connecting with the same
declaration in web.config to no effect using either a statically assigned
user or the connecting user.

--Chris
 
B

bruce barker

be sure the tool doesn't open any windows, as this will fail. service apps
(like asp.net) don't have access to the desktop, so they can not open any
windows (not even a messgebox).

-- bruce (sqlwork.com)


| I have a command line tool that I would like to run from my .NET web
| application using System.Diagnostics.ProcessStartInfo. I run cmd.exe with
| this and then pass the command to run the tool as an argument to the
process.
| When I try this from a Windows application it works fine, however, when I
do
| this from my web application I get errors.
|
| Both applications are running under the same users so am not sure if it is
a
| permissions problem.
|
| If anyone has an ideas it would be most appreciated. THANKS!
|
|
 
T

Tarren

do not just check the permissions, check the local group policy as well to
see if the aspnet account is locked out of being able to run the local
processes or something applicable

Also, test the verification to even check that you are impersonating
correctly (e.g. check out user name in debug)
 
G

Guest

After doing some reading, think its a permissions problem. My tool tries to
access another tool on another server, and impersonation will not work for
this, so am trying delegation instead, but seem to get that to work either.
Anyone got delegation working?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top