not able run batch file through window service code in asp.net RRS feed

  • Question

  •  Hi,

     I am using the code  to  run a  batch   file which is  located at specified location.

    i am using the code

    System.Diagnostics.Process process = new System.Diagnostics.Process();
                        process.StartInfo = new System.Diagnostics.ProcessStartInfo(@"d:\test.bat");
                        process.StartInfo.CreateNoWindow = false;
                        process.StartInfo.ErrorDialog = false;
                        process.StartInfo.RedirectStandardError = true;
                        process.StartInfo.RedirectStandardInput = true;
                        process.StartInfo.RedirectStandardOutput = true;
                        process.StartInfo.UseShellExecute = false;
                        process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;

    This code run   normally   when i use  it in  simple web page, but  when i use  this  inside  my  window  services  it  run without  any  effect.  I Am not able  to sort this  issue.

    Is IT  any issue related to security permission ,if  yes then where it needs to provide access  permission.

    please suggest.

    rishi [URL=http://miniclipgames.name/ ]miniclip[/URL], [URL=http://www.btjunkie.name/ ]btjunkie[/URL], [URL=http://www.freedownloadgames.name/ ]games[/URL]

    Friday, June 8, 2012 9:06 AM

All replies

  • Do'nt you need the shell execute to be true to create a new copy of cmd.exe?

     process.StartInfo.UseShellExecute = true;

    Are you piping inputs and output to the shell copmmand? You have both standard input and standard output and standard error set true.  If the bat file file has any input or ouput it will be blocked if you don't connect anything to the pipes.  You may want to add a stream to the standard output and standard error so you can see any error messages.


    Friday, June 8, 2012 4:07 PM