从Web应用程序运行命令行工具 [英] Running command line tool from web application

查看:83
本文介绍了从Web应用程序运行命令行工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个命令行工具,我想使用System.Diagnostics.ProcessStartInfo从我的.NET web

应用程序运行。我使用

运行cmd.exe,然后传递命令以运行该工具作为进程的参数。

当我从Windows应用程序尝试此操作时它工作正常但是,当我从我的网络应用程序中执行此操作时,我会收到错误。


两个应用程序都在同一个用户下运行,所以我不确定它是否是一个

权限问题。


如果有人有想法,那将非常感激。谢谢!

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!

推荐答案

Mandy,

默认情况下,ASP.NET应用程序由一个名为
$的进程托管b $ b aspnet_wp.exe。此过程在ASPNET用户帐户下运行。这位用户只有有限的特权。

。要在不同的用户下运行您的应用,您需要启用模拟。

将此添加到< configuration>中的web.config文件中部分。

< identity impersonate =" true" /取代。并关闭对页面的匿名访问

在IIS中。

这将在访问该页面的用户下运行您的应用程序。您可以

也给默认用户

< identity impersonate =" true"的userName = QUOT; contoso\Jane" password =" pass" />

http://msdn.microsoft.com/library/de...ersonation.asp


希望这有帮助


Rak

" Mandy"写道:
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:
我有一个命令行工具,我想使用System.Diagnostics.ProcessStartInfo从我的.NET web
应用程序运行。我使用
运行cmd.exe,然后传递命令以运行该工具作为进程的参数。
当我从Windows应用程序尝试此操作时它工作正常,但是,当我这样做时从我的Web应用程序中我得到错误。

两个应用程序都在同一个用户下运行,所以我不确定它是否是一个
权限问题。

如果有人有想法,将非常感激。谢谢!
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!



嗨Mandy,


没有必要启动cmd .exe实用程序。刚开始你想要开始的过程
。我不确定这是否与你的错误有关,因为你没有提到错误是什么。但是,我也从未尝试通过调用cmd.exe来运行

可执行文件。这可能是你问题的原因。

让我说明:

启动进程cmd.exe,带参数运行其他exe

cmd.exe启动

cmd.exe启动其他exe


Versus

启动流程期望的exe


-

HTH,

Kevin Spencer

Microsoft MVP

..Net开发人员

跟随者和贷款人都不是。

Mandy <马*** @ discussions.microsoft.com>在消息中写道

news:38 ********************************** @ microsof t.com ...
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...
我有一个命令行工具,我想使用System.Diagnostics.ProcessStartInfo从我的.NET web
应用程序运行。我用
运行cmd.exe然后传递命令来运行该工具作为
进程的参数。
当我从Windows应用程序尝试这个时它工作正常,但是,当我从我的网络应用程序做了这个我得到错误。

两个应用程序都在同一个用户下运行,所以不确定它是否是
>权限问题。

如果有人有想法,那将非常感激。谢谢!
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!



感谢你的帖子,但我已经开始模拟同一个

用户了Windows应用程序运行,并且该工具仍然会运行
...此用户可以完全控制该工具以及它所在的目录。
所在的位置。 />

" Rak"写道:
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,
默认情况下,ASP.NET应用程序由名为
aspnet_wp.exe的进程托管。此过程在ASPNET用户帐户下运行。这位用户只有有限的特权。要在其他用户下运行您的应用,您必须启用模拟。
将此添加到< configuration>中的web.config文件中。 section。
< identity impersonate =" true" /取代。并关闭对IIS中页面的匿名访问。
这将在访问该页面的用户下运行您的应用程序。您还可以给默认用户
< identity impersonate =" true"的userName = QUOT; contoso\Jane" password =" pass" />

http://msdn.microsoft.com/library/de...ersonation.asp

希望这会有所帮助

Rak

" Mandy"写道:
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:
我有一个命令行工具,我想使用System.Diagnostics.ProcessStartInfo从我的.NET web
应用程序运行。我使用
运行cmd.exe,然后传递命令以运行该工具作为进程的参数。
当我从Windows应用程序尝试此操作时它工作正常,但是,当我这样做时从我的Web应用程序中我得到错误。

两个应用程序都在同一个用户下运行,所以我不确定它是否是一个
权限问题。

如果有人有想法,将非常感激。谢谢!
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!



这篇关于从Web应用程序运行命令行工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆