编辑从C#.ashx的运行的Cscript.exe不VBScript文件执行代码
我在一些错误处理添加到我的.vbs文件,并且它确实是一个权限问题(我现在碰到一个“Permission拒绝错误“)。但是,在web.config <impersonate>
标记中提供我的凭据似乎没有任何效果。
还试图通过时,通过
p.StartInfo.Password = Misc.CreateSecurityString("password");
p.StartInfo.UserName = "admin";
我得到一个新的错误提供我的凭据的过程:
cscript.exe - Application error
The application failed to initialize properly (0xc0000142). Click on OK to terminate the application.
喊出来,如果你知道是什么导致了这一点。 (或只是键入它...)
感谢您的帮助到目前为止!
背景
我试图从一个自定义的处理器(ashx的)执行.vbs文件。 VBScript正在iis 5.1中设置一个Web应用程序。
到目前为止,下面的代码执行没有错误
string sToRun = "C:\CreateIISApplication.vbs"
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "cscript";
p.StartInfo.Arguments = sToRun;
p.Start();
// Do not wait for the child process to exit before
// reading to the end of its redirected stream.
// p.WaitForExit();
// Read the output stream first and then wait.
string sOutput = p.StandardOutput.ReadToEnd();
p.WaitForExit();
问题
我的问题是,VBScript中似乎根本就不会运行。当我检查IIS时,我的应用程序未被创建。
当我直接从命令提示符运行脚本文件时,一切正常,我的应用程序显示在IIS中。
故障排除
我决定添加一些回声报表到.vbs文件,所以我可以确保它正在运行。在命令行中,所有语句都可以正确输出。当检查字符串sOutput时,我得到标题消息,但没有我的后续消息。
从C# - sOutput
Microsoft (R) Windows Script Host Version 5.7 Copyright (C) Microsoft Corporation. All rights reserved
的内容通过命令行
Microsoft (R) Windows Script Host Version 5.7 Copyright (C) Microsoft Corporation. All rights reserved
Hello
所以我可以证明(我认为).vbs文件不被评估,并且正在调用cscript。如果我在不引用.vbs文件的情况下调用cscript,那么我将获得帮助文档。所以有些事情出错了。
任何想法?谢谢!
@Mike&@马特 - 感谢您的帮助,请参阅我的编辑,您可以提供的任何进一步的帮助将会很棒! – 2010-10-01 19:38:11