如何从Asp.Net应用程序启动进程 [英] How Do I Start A Process From Asp.Net Application

查看:80
本文介绍了如何从Asp.Net应用程序启动进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有一个简单的ASP.NET应用程序,它有一个按钮btn1。当我点击btn1我想启动一个可执行文件,例如c:\\\\ myfile.exe。



1.当我从视觉上运行应用程序时Studio 2010一切正常。

2.当我在另一个系统上从IIS运行应用程序,甚至从同一系统上的IIS运行应用程序时myfile.exe启动但它从未在桌面上显示。 />


i检查任务管理器myfile.exe正在运行的应用程序。



我试过很多东西被建议像冒充,使用本地系统运行IIS服务并检查与桌面交互....



这些都不起作用。



你能帮忙一步一步推荐



最好的问候



Ben

Hello i have a simple ASP.NET Application that has a button btn1. when i click the btn1 i want to start an executable file for example c:\test\myfile.exe .

1. when i run the application from visual Studio 2010 all works fine.
2. when i run the application from IIS on another system or even from IIS on the same system the process myfile.exe starts but it never shows on the Desktop.

i checked the task manager the application myfile.exe is running.

I tried many things was suggested like impersonation, running the IIS Service with local system and check interact with desktop....

non of these worked.

Can you please help and give step by step recomendations

Best Regards

Ben

推荐答案

您的代码运行的帐户将是匿名用户,该用户无法访问登录用户的桌面。它适用于您你的代码在你的帐户下运行本地机器,因此可以访问你的桌面。



您需要将匿名用户更改为登录时的帐户用户可以访问桌面的exe。请注意,您无法在客户端上启动exes或访问客户端的桌面。由于没有人在服务器上查看GUI,或者服务器可能没有人登录,即使正在尝试做的事情也没有意义,将代码重新编写为控制台应用程序或不需要GUI的东西。
The account your code is running under will be the anonymous user which doesn't have access to the desktop of the person who is logged in. It works on your local machine as your code is running under your account so has access to your desktop.

You need to change the anonymous user to the same account as the logged-in user for the exe to have access to the desktop. Note that you can't launch exes on the client or access the client's desktop. As no-one is on the server in order to see the GUI, or the server might have no-one logged in, it's a little pointless even doing what you're trying to do, re-write your code as a console app or something that needs no GUI.


简单。

在开发中,您的客户端和服务器是同一台计算机。这意味着当你的C#代码启动一个进程,或者显示一个消息框你就会看到它。



在生产中...它们不是。因此,在服务器上执行的C#代码在服务器上启动进程,该进程使用IIS权限在服务器上运行。客户永远不会看到它。应用程序很可能根本不会运行,因为IIS运行时使用该文件夹没有足够的访问权限:这是非常正常的,以防止恶意应用程序做出令人讨厌的事情。要解决这个问题,你必须确保为该文件夹提供足够的权限。



但有一件事是肯定的:你的C#代码不能和不会启动客户端将能够看到的进程。
Simple.
In development, your Client and Server are the same computer. Which means that when your C# code starts a process, or displays a message box you get to see it.

In production...they aren't. So the C# code - which is executed on the server - starts a process on the server, which runs on the server using IIS permissions. The client will never see it. There is a good chance that the app will not run at all, because the use that IIS is running under doesn;t have sufficient access permissions for the folder: that's pretty normal, to prevent rogue apps from doing nasty things. To fix that, you would have to ensure the sufficient permissions are given to that folder for teh right individual.

But one thing is for sure: your C# code cannot and will not start a process that the client will ever be able to see.


这篇关于如何从Asp.Net应用程序启动进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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