Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

calling a batch file from windows service

$
0
0
<div class="votecount">Hi</div> <div class="container"> <div class="body">

I have the following piece of code that I am trying to run from a windows service to execute a batch file. But its not running. Can someone help me in finding out whats wrong with it. There is no error but the batch file does not run.

Thanks

string BatchPath = ConfigurationManager.AppSettings["BatchPath1"];
System.Diagnostics.Process proc = new System.Diagnostics.Process();
                        System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(BatchPath);

                        info.UseShellExecute = false;
                        info.RedirectStandardError = true;
                        info.RedirectStandardInput = true;
                        info.RedirectStandardOutput = true;
                        info.CreateNoWindow = false;
                        info.ErrorDialog = true;
                        info.WindowStyle = ProcessWindowStyle.Normal;
                        proc.StartInfo = info;
                        proc.Start();
                        System.Threading.Thread.Sleep(10000); // simulate doing other things...
                        proc.StandardInput.WriteLine("exit"); // tell console to exit

</div> </div>

Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>