[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

keep bat file running inside C# service.

Posted on 2009-04-28
3
Medium Priority
?
945 Views
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;
            process.Start();
        }
 
        protected override void OnStop()
        {
        }

Open in new window

0
Comment
Question by:casit
  • 2
3 Comments
 
LVL 26

Assisted Solution

by:Anurag Thakur
Anurag Thakur earned 2000 total points
ID: 24248473
is the following link of any help in the execution of batch files
http://stackoverflow.com/questions/361097/c-service-cannot-execute-batch-file
0
 

Accepted Solution

by:
casit earned 0 total points
ID: 24248607
I actually figured it out after posting the question.
Here is the link
http://gpwiki.org/forums/viewtopic.php?t=7753
And the following is the code for anyone else.
System.Diagnostics.Process.Start("cmd.exe", @"/c C:\tracd.bat");

Open in new window

0
 
LVL 26

Expert Comment

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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month17 days, 14 hours left to enroll

830 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