ASP.Net 페이지를 통해 서버에서 배치 파일을 실행하려고하면 내 미친 소리가납니다. 아래 코드를 실행하면 아무런 문제가 없습니다.이 코드가 실행되는 일부 로그 문을 볼 수는 있지만 함수에 전달한 .bat 파일은 절대 실행되지 않습니다.ASP.Net 페이지에서 배치 파일 실행
아무도 내가 뭘 잘못하고 있다고 말할 수 있습니까?
오류있는 응용 프로그램 cmd.exe를, 버전 6.0.6001.18000을 :에서
public void ExecuteCommand(string batchFileLocation) { Process p = new Process(); // Create secure password string prePassword = "myadminpwd"; SecureString passwordSecure = new SecureString(); char[] passwordChars = prePassword.ToCharArray(); foreach (char c in passwordChars) { passwordSecure.AppendChar(c); } // Set up the parameters to the process p.StartInfo.FileName = @"C:\\Windows\\System32\cmd.exe"; p.StartInfo.Arguments = @" /C " + batchFileLocation; p.StartInfo.LoadUserProfile = true; p.StartInfo.UserName = "admin"; p.StartInfo.Password = passwordSecure; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; // Run the process and wait for it to complete p.Start(); p.WaitForExit(); }
은 '응용 프로그램'이벤트 뷰어, 서버에 내가 이것을 실행하려고 할 때마다 로그, 다음과 같은 문제가 발생하는 것 같습니다 , 타임 스탬프 0x47918bde, 오류 모듈 kernel32.dll, 버전 6.0.6001.18000, 타임 스탬프 0x4791a7a6, 예외 코드 0xc0000142, 오류 오프셋 0x00009cac, 프로세스 ID 0x8bc, 응용 프로그램 시작 시간 0x01cc0a67825eda4b.
UPDATE
다음 코드는 잘 작동은 (는 배치 파일을 실행) :
Process p = new Process();
p.StartInfo.FileName = batchFileLocation;
p.StartInfo.WorkingDirectory = Path.GetDirectoryName(batchFileLocation);
p.StartInfo.UseShellExecute = false;
// Run the process and wait for it to complete
p.Start();
p.WaitForExit();
이 그러나하지 않습니다 (내가 특정 사용자로 실행하려고 할 때) :
Process p = new Process();
// Create secure password
string prePassword = "adminpassword";
SecureString passwordSecure = new SecureString();
char[] passwordChars = prePassword.ToCharArray();
foreach (char c in passwordChars)
{
passwordSecure.AppendChar(c);
}
p.StartInfo.FileName = batchFileLocation;
p.StartInfo.WorkingDirectory = Path.GetDirectoryName(batchFileLocation);
p.StartInfo.UseShellExecute = false;
p.StartInfo.UserName = "admin";
p.StartInfo.Password = passwordSecure;
// Run the process and wait for it to complete
p.Start();
p.WaitForExit();
이것은 내가보기에 문제가있는 것처럼 보입니다 .- 불행히도 IIS 포럼 스레드의 솔루션에 대한 링크가 다운 된 것처럼 보입니다. –