简体   繁体   English

从ASP.NET应用程序启动进程时cscript崩溃

[英]cscript crashes when starting a process from ASP.NET Application

I´m having a problem with my ASP application. 我的ASP应用程序有问题。 I´m getting an error from the cscript when I run a process on the server. 在服务器上运行进程时,cscript出现错误。 When I debug locally the page just works fine and the process is executed correctly, but when I deploy the application to the IIS and run it from another machine explorer it crashes when the process starts. 当我在本地调试页面时,它可以正常工作并且正确执行了该过程,但是当我将应用程序部署到IIS并从另一个计算机资源管理器运行它时,该进程启动时会崩溃。

I imagine it was a matter of the user, so I added this line to the web.config, to ensure that. 我想这是用户的事,所以我将这一行添加到web.config中以确保这一点。

<identity impersonate="true" userName="domain\user" password="password" />

Then, I added the user that I wanted the process to start with but the page keeps crashing. 然后,我添加了我希望该过程开始的用户,但是页面不断崩溃。 The error that I get in the server side each time the process is launch (when a button is pressed) is: 每次启动进程(按下按钮时),我在服务器端遇到的错误是:

cscript.exe - Application Error cscript.exe-应用程序错误

The application failed to initialize properly (0xc0000142). 应用程序无法正确初始化(0xc0000142)。 Click on OK to terminate the application 单击确定终止应用程序

The code that launches the process is: 启动该过程的代码是:

    public static void actualizarPersona(csPersona persona)
    {

        string nombreArchivo = "card.js";

        File.WriteAllText(nombreArchivo, persona.setFileActualizarPersona(persona), Encoding.GetEncoding(1252));


        Process proc = new Process();

        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.CreateNoWindow = true;
        startInfo.UseShellExecute = false;
        startInfo.RedirectStandardOutput = true;
        startInfo.RedirectStandardError = true;
        startInfo.FileName = "cscript.exe";
        startInfo.Arguments = nombreArchivo;
        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
        startInfo.UserName = "Administrator";

        SecureString password = new SecureString();
        string contraseña = "myPassword";
        foreach (char c in contraseña)
        {
            password.AppendChar(c);
        }

        startInfo.Password = password;
        proc.StartInfo = startInfo;
        proc.Start();
        proc.WaitForExit();
        proc.Close();
        proc.Dispose();
    }

Does anyone have any idea of what may be happening?. 有谁知道会发生什么? I´ve been stuck here for a while today. 我今天在这里停留了一段时间。

Thanks you. 谢谢。

You may need to load the user's profile 您可能需要加载用户的个人资料

startInfo.LoadUserProfile = true startInfo.LoadUserProfile = true

Edit 编辑

Try creating a new app pool with aa new admin account. 尝试使用一个新的管理员帐户创建一个新的应用程序池。 If that works remove the user from the admin group and create a new group with the necessary permissions for the app. 如果可行,请从管理组中删除该用户,然后创建一个具有该应用程序必要权限的新组。

(see trying to run a process from an asp.net application ) (请参阅尝试从asp.net应用程序运行进程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM