나는 사용자를 보유하고 있으며, "MyUser"라고 부르기로한다. 암호가 있는데, 암호가 "암호"라고 가정합니다. 이 사용자에게는 git에 대한 SSH 키가 있습니다. 내 ASP.NET 응용 프로그램에서 자식 파일 명령을 실행하는 배치 파일을 실행하려고하면 매개 변수로 전달되는 위치에 있습니다.다른 사용자가있는 배치 파일에서 힘내 당기기
private void ExecuteCommand(string path, int timeout)
{
Process process = new Process();
process.StartInfo = new ProcessStartInfo();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = "\"" + path + "\"";
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
//processInfo.WorkingDirectory = Config.GitHubRepoPath;
process.StartInfo.UserName = "MyUser";
process.StartInfo.Password = new System.Security.SecureString();
process.StartInfo.Password.AppendChar('P');
process.StartInfo.Password.AppendChar('a');
process.StartInfo.Password.AppendChar('s');
process.StartInfo.Password.AppendChar('s');
process.StartInfo.Password.AppendChar('w');
process.StartInfo.Password.AppendChar('o');
process.StartInfo.Password.AppendChar('r');
process.StartInfo.Password.AppendChar('d');
// *** Redirect the output ***
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
// *** Read the streams ***
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
if (timeout <= 0)
{
process.WaitForExit();
}
else
{
process.WaitForExit(timeout);
}
int exitCode = process.ExitCode;
process.Close();
return new ShellCommandReturn { Error = error, ExitCode = exitCode, Output = output };
}
을하지만이 기능을 실행할 때 ExitCode를가 -1073741502과 오류 출력이 비어 다음과 같이 내 기능입니다. 어떻게이 문제를 해결할 수 있습니까?
제발 도와주세요, 나는 이것을 문자 그대로 며칠 동안 풀려고 노력했습니다.
이 코드를 사용하여 배치 파일을 성공적으로 실행할 수 있습니까? –
예, git pull이 포함되어 있지 않으면. –
그것이 나 였다면 다음 번에 배치 파일이 실행되는 계정에 적절한 권한이 있는지 확인해야합니다. (그러나 그것은 나뿐입니다.) –