本文介绍了哪些权限才能实现通过asp.net应用程序的Process.Start?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用的Process.Start调用可执行(Graphviz的)一个asp.net应用程序。在我的开发环境中工作得很好,但是当我移动到生产,我没能获得运行过程。这里的细节。

我创造了这个简单的分显示的问题。

保护小组的Page_Load(发送者为对象,E作为EventArgs的)把手Me.Load    昏暗ProcessInfo作为的ProcessStartInfo
    ProcessInfo =新的ProcessStartInfo    'ProcessInfo.Domain =XXXXXXX
    ProcessInfo.UserName =XXXXXX
    昏暗PwdString作为字符串=XXXXXXX
    昏暗newPass作为为System.Security.SecureString
    newPass =新为System.Security.SecureString
    对于每个C为CHAR在PwdString
        newPass.AppendChar(三)
    下一个C
    ProcessInfo.Password = newPass    'ProcessInfo.FileName =C:\\ WINDOWS \\ SYSTEM32 \\ Notepad.exe的
    'ProcessInfo.FileName =C:\\ TEST.BAT
    ProcessInfo.FileName =C:\\ Program Files文件(x86)的\\ Graphviz2.30 \\ BIN \\ dot.exe
    ProcessInfo.Arguments =-Kdot -Tsvg C:\\ Test.dot -PC:\\ Test.svg
    ProcessInfo.RedirectStandardOutput = TRUE
    ProcessInfo.UseShellExecute = FALSE
    ProcessInfo.CreateNoWindow = TRUE    昏暗的过程流程
    流程=新工艺
    Process.StartInfo = ProcessInfo
    的Process.Start()    等到过程传回一个退出code
    Process.WaitForExit()    尝试
        昏暗ProcessResults的String = Process.StandardOutput.ReadToEnd
        Output.Text = ProcessResults
    抓住EX为例外
        Output.Text = ex.ToString
    结束Try结束小组

这里有三个场景。首先,我测试只是开始记事本。
- 开发工程
- 生产工程(这是我能得到生产工作的唯一案例)

其次,我创建了一个在打开一个记事本文档简单的批处理文件。 (记事本C:\\ test.dot)


  • 开发工作

  • 生产不能正常工作

第三,我已经打电话的Graphviz的dot.exe。这就是我试图获得另一页的工作。


  • 开发工作

  • 生产不能正常工作

在所有的情况下,生产不能正常工作,我可以重现此问题
- 如果我加一个冒充= true来我的web.config的话,我没有得到任何错误了。该网页运行,就好像它是成功的。


  • 如果我不添加一个冒充的配置,但不要添加凭据ProcessInfo对象,则该页面将再次运行没有错误。该过程没有在开始生产,虽然


  • 如果我不加的假冒或ProcessInfo凭据,那么我会得到一个错误。这是错误的输出。


Exception Details: System.ComponentModel.Win32Exception: Access is
denied

Source Error:    
Line 36:         Process = New Process
Line 37:         Process.StartInfo = ProcessInfo
Line 38:         Process.Start()
Line 39:
Line 40:         'Wait until the process passes back an exit code

Source File:  C:\Inetpub\vhosts\leapfrogbi.com\httpdocs\test\ProcessStart.aspx.vb Line:  38 

Stack Trace:    
[Win32Exception (0x80004005): Access is denied]   
System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) +2161
System.Diagnostics.Process.Start() +150   
Test_ProcessStart.Page_Load(Object sender, EventArgs e) in C:\Inetpub\vhosts\leapfrogbi.com\httpdocs\test\ProcessStart.aspx.vb:38
System.Web.UI.Control.OnLoad(EventArgs e) +91   
System.Web.UI.Control.LoadRecursive() +74   
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

I have tried a variety of security related settings. Currently my app pool is running with an identity that is a local administrator. I have also tried adding everyone to the administrators group in an attempt to see if security was the root problem.

Also, I am using Plesk to manage my domain. I have searched extensively for any options that might be affecting this situation, and have found not yet. Again, process start does work in production when making a simple call to start notepad. It is very hard to narrow this down without more verbose logs.

Thank you in advance for any help you can offer. This is driving me nuts.

解决方案

Locate your pool under witch your site is run, and see under witch user is running.

If you can not do that you can run this code to see the user that your pool is running:

var user = System.Security.Principal.WindowsIdentity.GetCurrent().User;
var userName = user.Translate(typeof(System.Security.Principal.NTAccount));

And then give permission to that user to be able to run this files.

reference: How to find out which account my ASP.NET code is running under?

这篇关于哪些权限才能实现通过asp.net应用程序的Process.Start?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 09:16