通过ASP.NET/C#运行在IIS服务器上的过程 [英] Running Process on Server via ASP.NET/C# on IIS

查看:515
本文介绍了通过ASP.NET/C#运行在IIS服务器上的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所试图做的是运行在的Web服务器的桌面上单击按钮时的批处理文件。这是我迄今。

What I am trying to do is run a batch file that is located on the webserver's desktop when a button is clicked. This is what I have thus far.

ProcessStartInfo psi = new ProcessStartInfo("Notepad.exe");
   psi.WorkingDirectory = @"C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories";
   psi.UseShellExecute = false;
   psi.UserName = "administrator";  //username
   psi.Password = secure;  //secure string
var process = Process.Start(psi);

当我调试它,它不正是我想要它,但是当我访问该网站上的IIS(本地主机:81)批处理文件运行从来没有。我试过的ProcessStartInfo许多不同的变体和过程,没有运气。我测试过的用户名和密码,他们都太修正

When I debug it, it does exactly what I want it to, but when I access the site on IIS (localhost:81) the batch file never runs. I've tried many different variants of ProcessStartInfo and Process with no luck. I've tested the username and password and they are both correct too.

我没有得到任何错误,只是按键触发页面后回来。

I don't get any errors, the button just triggers a page post back.

我给IUSR和IIS_IUSRS权限的文件,仍然没有运行。我也删除了用户名和密码,UseShellExecute设置为true,但什么也没做,以及。

I have given IUSR and IIS_IUSRS permissions to the file, and still nothing runs. I also removed the username and password and set the UseShellExecute to true, but that did nothing as well.

编辑:

看起来每个人都认为它的一些权限。我需要什么你知道怎样做才能让IIS打开进程?

It looks like everyone thinks its some permissions. Any idea on what I need to do to allow IIS to open the process?

在此先感谢!

推荐答案

就在第三行改成这样:

  psi.UseShellExecute = true;

或阅读这篇文章,它真正得到完成的工作:

or read this article which really gets the work done:

http://support.microsoft.com/default。 ?ASPX SCID = KB; EN-US; 889251

这篇关于通过ASP.NET/C#运行在IIS服务器上的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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