Akash Dani

Akash Dani

  • NA
  • 87
  • 23.4k

Batch file is not working in IIS?

Jul 29 2019 12:05 AM
My Code:

StreamWriter sw = File.CreateText("C:\\inetpub\\wwwroot\\StarRECON_TEST_PADSS\\Files\\" + "TESTDEL.bat");
sw.WriteLine("set _p= %-p%");
sw.WriteLine("sdelete _p 7 " + sourcePath + FileName);
sw.Close();

Process p = new Process();
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.FileName = "C:\\inetpub\\wwwroot\\StarRECON_TEST_PADSS\\Files\\" + "TESTDEL.bat";
Write(p.StartInfo.FileName);
p.StartInfo.UseShellExecute = false;
p.StartInfo.WorkingDirectory = Environment.CurrentDirectory;
Write(p.StartInfo.WorkingDirectory);
p.StartInfo.RedirectStandardError = true;
Write("Sdelete BatchFile: Start() Execution Started");
p.Start();
p.WaitForExit();
Write("Sdelete BatchFile: WaitForExit() Execution Ended");
p.Dispose();
 
 
The above code is creating .bat file correctly but the batch file is not executing in IIS but when I run it manualy its working but when I run it in IIS it is not working.

Answers (5)