我必须从我们的内部网站运行一个工具。用户将从用户界面提供的输入很少,然后我想用用户凭证运行该工具。当我从本地机器运行它时,我的代码工作正常,但是当我将它部署到生产服务器并尝试从该服务器执行它时,它不会启动任何内容。未从生产Web服务器运行的应用程序
这是我的代码,任何意见将不胜感激。
System.Diagnostics.ProcessStartInfo PSI = new System.Diagnostics.ProcessStartInfo(@"D:\run.bat");
PSI.UserName = "username";
PSI.Domain = "domain";
System.Security.SecureString securePwd = new System.Security.SecureString();
string password = "password";
foreach (char c in password)
{
// Append the character to the password.
securePwd.AppendChar(c);
}
PSI.Password = securePwd;
PSI.UseShellExecute = false;
process.StartInfo = PSI;
PSI.Arguments = SiteId.Text + " " + WebServiceUrl.Text + " " +LogFile.Text;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
这可能听起来很愚蠢,但是你确定你已经在服务器上部署了'run.bat'(并且该服务器也有一个D:\驱动器)? – SirViver 2011-05-14 21:58:40
还是权限? – 2011-05-14 22:01:03
是的run.bat在该位置可用。当我登录到该服务器后手动运行它时,它工作正常。 – 2011-05-14 22:02:50