Web services 应用程序未能正确初始化(0xc0000142)

Web services 应用程序未能正确初始化(0xc0000142),web-services,iis,authentication,exe,impersonation,Web Services,Iis,Authentication,Exe,Impersonation,我正在尝试使用process.Start()从web服务启动notepad.exe(作为更简单的测试)。此web服务已部署到Windows XP上的IIS 5.1(用于开发),并可能部署到带有IIS 6的Windows 2003服务器。这是我正在使用的代码: [WebMethod] public String ReqFormImage(String qString) { _qString = qString; String imageLo

我正在尝试使用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时会出现问题,但我需要这样才能工作。我肯定这不是最好的做法,但我的时间不够,正在寻找解决办法。就目前而言,至少让记事本上市就足够了


谢谢您的帮助。

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