【问题标题】:Application Failed to Initialize Properly (0xc0000142)应用程序无法正确初始化 (0xc0000142)
【发布时间】:2012-03-19 08:41:12
【问题描述】:

我正在尝试使用 process.Start() 从 Web 服务启动 notepad.exe(作为更简单的测试)。此 Web 服务部署到 Windows XP 上的 IIS 5.1(用于开发),并且可能会部署到具有 IIS 6 的 Windows 2003 服务器。这是我正在使用的代码:

    [WebMethod]
    public String ReqFormImage(String qString)
    {
        _qString = qString;

        String imageLoc = @"http://localhost/MobileService/formImages/" + NameOfScreenshot(qString);

        Process myProcess = new Process();
        try
        {
            //Credentials
            myProcess.StartInfo.Domain = "domain";
            myProcess.StartInfo.UserName = "myUserName"; //local admin on development pc
            myProcess.StartInfo.Password = PasswordGenerate("removed");

            //StartInfo
            myProcess.StartInfo.WorkingDirectory = @"C:\WINDOWS\System32";
            myProcess.StartInfo.FileName = "notepad.exe";
            //myProcess.StartInfo.Arguments = qString;
            myProcess.StartInfo.UseShellExecute = false;
            myProcess.StartInfo.RedirectStandardInput = true;
            myProcess.StartInfo.RedirectStandardOutput = true;
            myProcess.StartInfo.RedirectStandardError = true;
            //myProcess.StartInfo.LoadUserProfile = false;

            myProcess.Start();
            myProcess.WaitForExit();
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
return imageLoc;
    }

我还在 web.config 中将 impersonate 设置为 true(我尝试过在配置文件中使用和不使用我的凭据,以及将 impersonate 设置为 false)。我还授予了我的用户 ID、aspnet 和 notepad.exe 上的服务帐户的读取/执行权限。

myProcess.WaitForExit() 上的断点会导致弹出一个消息框,显示“应用程序无法正确初始化 (0xc0000142)”。我查看了事件日志,没有比这更进一步的信息了。

我最终需要的是能够启动一个模拟帐户的 exe,该帐户可以被硬编码或模拟访问 Web 服务的用户。我知道使用 GUI 服务器端打开 exe 存在问题,但我需要它才能工作。我确定这不是最佳做法,但我的时间不多了,正在寻找解决方法。目前,至少启动记事本就足够了。

感谢您的帮助。

【问题讨论】:

    标签: web-services iis authentication exe impersonation


    【解决方案1】:

    在 IIS 中,我必须将 Web 服务设置为运行脚本和可执行文件,而不仅仅是脚本。记事本现在启动,但没有完整的 GUI。我不认为我需要的东西是可能的,但我解决了我的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-20
      • 2011-02-23
      • 2011-04-02
      • 1970-01-01
      • 2011-03-06
      • 1970-01-01
      相关资源
      最近更新 更多