keep bat file running inside C# service.

Posted on 2009-04-28
Last Modified: 2012-08-13
I have the following C# code.  I want it to call the C:\tracd.bat file and keep it running.
Then on stop close the process.  Any ideas?
protected override void OnStart(string[] args)


            Process process = new Process();

            // Configure the process using the StartInfo properties.

            process.StartInfo.FileName = "C:\tracd.bat";

            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

            process.StartInfo.CreateNoWindow = true;



        protected override void OnStop()



Open in new window

Question by:casit
    LVL 26

    Assisted Solution

    by:Anurag Thakur
    is the following link of any help in the execution of batch files

    Accepted Solution

    I actually figured it out after posting the question.
    Here is the link
    And the following is the code for anyone else.
    System.Diagnostics.Process.Start("cmd.exe", @"/c C:\tracd.bat");

    Open in new window

    LVL 26

    Expert Comment

    by:Anurag Thakur
    i think you can close the question yourself instead of asking the moderators to do so

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    ViewModel data appears to be caching in Razor View 2 29
    Refresh page ASP.NET C# 3 39
    Problem to event 3 27
    report c# 9 60
    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now