Bir ASP.Net sayfası aracılığıyla bir sunucuda bir toplu iş dosyasını çalıştırmaya çalışıyorum ve bu benim çılgınlığımı sürüyor. Aşağıdaki kodu çalıştırdığımda, hiçbir şey mutlu değil - Bazı kod deyimlerinden bu kodun çalıştığını görebiliyorum, ancak işleve ilettiğim .bat dosyası hiçbir zaman çalışmaz.Bir ASP.Net sayfasından toplu iş dosyasını çalıştırma
Lütfen bana neyi yanlış yaptığımı söyler misiniz?
Hatalı uygulama cmd.exe'yi, sürüm 6.0.6001.18000: In
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(); }
'Application' Olay Görüntüleyici, sunucuda bunu çalıştırmayı deneyin her zaman log aşağıdaki sorun ortaya görünmektedir , zaman damgası 0x47918bde, modülü kernel32.dll, sürüm 6.0.6001.18000, zaman damgası 0x4791a7a6, özel durum kodu 0xc0000142, hata 0x00009cac, işlem kimliği 0x8bc, uygulama başlangıç zamanı 0x01cc0a67825eda4b hata.
GÜNCELLEME
şu kod çalışıyor (Bu toplu iş dosyasını çalıştıran):
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();
Ancak bu does not (i belirli bir kullanıcı olarak çalıştırmayı denediğinizde):
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();
Bu, iyi görüyorum sorun gibi görünüyor - maalesef IIS forumu çözümden çözüm bağlantı aşağı görünüyor gibi görünüyor. –