By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,655 Members | 1,860 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,655 IT Pros & Developers. It's quick & easy.

Running command line tool from web application

P: n/a
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!
Nov 19 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Rak
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/de...ersonation.asp

hope this helps

Rak
"Mandy" wrote:
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!

Nov 19 '05 #2

P: n/a
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.
"Mandy" <Ma***@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.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!

Nov 19 '05 #3

P: n/a
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.

"Rak" wrote:
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/de...ersonation.asp

hope this helps

Rak
"Mandy" wrote:
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!

Nov 19 '05 #4

P: n/a
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...

"Rak" wrote:
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/de...ersonation.asp

hope this helps

Rak
"Mandy" wrote:
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!

Nov 19 '05 #5

P: n/a
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!

"Kevin Spencer" wrote:
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.
"Mandy" <Ma***@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.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!


Nov 19 '05 #6

P: n/a
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.

"Mandy" <Ma***@discussions.microsoft.com> wrote in message
news:B0**********************************@microsof t.com...
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!

"Kevin Spencer" wrote:
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.
"Mandy" <Ma***@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.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!
>
>


Nov 19 '05 #7

P: n/a
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

"Mandy" <Ma***@discussions.microsoft.com> wrote in message
news:B0**********************************@microsof t.com...
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!

"Kevin Spencer" wrote:
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.
"Mandy" <Ma***@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.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!
>
>


Nov 19 '05 #8

P: n/a
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)
"Mandy" <Ma***@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.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!
|
|
Nov 19 '05 #9

P: n/a
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)
"Mandy" <Ma***@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.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!

Nov 19 '05 #10

P: n/a
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?

"Chris Dickens" wrote:
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

"Mandy" <Ma***@discussions.microsoft.com> wrote in message
news:B0**********************************@microsof t.com...
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!

"Kevin Spencer" wrote:
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.
"Mandy" <Ma***@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.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!
>
>


Nov 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.