473,385 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Running command line tool from web application

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
10 3794
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Peter Rilling | last post by:
I have an EXE that I would like to be able to run from either the command-line or as a windows service. Is there a way that I can tell which context the program is running in? Basically, if it...
4
by: Boris | last post by:
I observe the following strange behavior of my application. Let say we have managed application MyApp.exe which depend on a few assemblies MyAssembly1.dll, MyAssembly2.dll and MyAssembly3.dll. The...
0
by: WATYF | last post by:
This is my problem... I have some code that starts a Process and returns it to a variable... (prcBat) At any time while that process is running... I want to be able to Kill it by pressing a...
3
by: ° ^F®êâK^ ° | last post by:
Blank hi there, I just want to explain my problem. There is an application which is coded by me running. It is an vb.net application having user controls windows forms and something like visual...
5
by: clsmith66 | last post by:
I've been asked to find out if a project is possible, but I'm not having much luck finding the information I need, I hope some one can help. I need to see if I can build a windows service on the...
13
by: John Salerno | last post by:
If I want to write my code in a separate text editor (I like UltraEdit) but then press a single button to have that code run in the IDLE environment, is that possible? I know that you can configure...
2
by: pamela fluente | last post by:
I have an application running. A file type is registered with this application. When the user click on a file of such type a new instance of the application is loaded with command line (file name)....
51
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the how to know whether the script is running under...
1
by: =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post by:
On reflection, you could possibly make the app a self extracting zip file which extracts the EXE and a settings file and then starts the app, then when you app closes, it can repack the settings...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.