Click here to Skip to main content
15,171,576 members
Articles / Programming Languages / C#
Posted 20 Mar 2015


17 bookmarked

Batch IDE

Rate me:
Please Sign up or sign in to vote.
4.63/5 (23 votes)
20 Mar 2015CPOL3 min read
Small tool to write, run batch codes


Today's project is somehow special, the way it allows you to learn how to create a simple IDE for Batch language which is related to Windows' commands. It will shows you good tricks to use System.IO & RichTextBox controller tricks too.


As any Windows user, I do use Windows' DOS commands and I did create a lot of .bat applications before.

Honestly, writing batch codes in a Notepad, then saving them as .bat extensions to use them later is a waste of time. That's why I needed to create a simple debugger which contains 1 TextBox (to write the codes) & 1 button (to debug them).

By the time, I developed my own project and it really helped me. Therefore, I want to post my full project here.

Why Should I Create or Use a Project Like This?

Well, let's throw our cards on the table:

  1. This project will solve the problem of wasting time, in other words, you won't need to write and save your batch codes as a .bat file to execute them later because using this project you can execute the codes directly.
  2. How can it help me? Good question, as I said before, you won't waste time anymore by saving your code and executing them after. Also, the environment that this project gives to you is pretty much better than the basic Notepad in my opinion.
  3. The code here is pretty useful - the ways that you will learn about new tricks about richTextBox controller and other Visual Studio tools.

Using the Code

The code which is used in this project is too easy, the most important part here is 'Debugging the code' part. I created a class library which contains the debugging method.

Debug the code class (class library: Batch compiler project ==> Compiler.cs)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
//I used System.IO to manipulate the .bat file
using System.IO;
//I used this system too to run the created file (test.bat) file
using System.Diagnostics;
namespace Batch_Compiler
    public  class Compiler
        public static void Debug(string code)
            string path = Path.GetTempPath() + "test.bat" ; //this string called path 
            	//contains the path where the .bat file (which contains the codes will be saved at) .
            File.WriteAllText(path, code); // This code will create the (test.bat) file into Temp folder .
            Process.Start(path); // This Code will run & execute it .
  • Variable code will contain the text which is written in the RichTextBox.
  • Variable path will contain the path where the file will be saved at.

Now let's go back to the main project

Import the reference

Right click on "References", result:

Click on "Add Reference..." then this window will appear:

As you can see, we only have created one project beside our main project. So simply click on OK button to import it. Done!

Import the library and the debug method

After we imported our reference (Batch_Compiler) we have to use it, add this code:

using Batch_Compiler;

Then, add this code to create a new variable:

public Batch_Compiler.Compiler Compiler = new Batch_Compiler.Compiler();

Debug (Run the code)

Now let's go to the last part of our project, debugging the code part. All that you have to do is:

  1. Rename your richTextBox controller to "Batch" (just an example)
  2. Double click on Debugging button, then add this code:
  • Compiler is the variable which we created from the start
  • Debug is the method that we imported from Batch_Compiler class, it is the method that is used to compile the code (save, then execute it)
  • Batch is our richTextBox controller that we named "Batch" .

Now you can build your project.

Public Variables

  • Open: OpenFileDialog controller
    public OpenFileDialog Open = new OpenFileDialog();
  • Save: SaveFileDialog controller
    public SaveFileDialog Save = new SaveFileDialog();

How to Use the Tool

To use this application as a user, you have to go through these easy steps:

  • Execute it
  • Write your batch code, example:
    @echo off
    Echo Test :: this code to write "Test" 
  • Debug it using the yellow button .

That's it.

What Can I do Using This Software?

  • You can use the software to write your own batch codes.
  • You can save them as Batch file or Text file.
  • You can debug the batch code directly without the need to save the code into .bat file.
  • You can save the batch codes into a .bat file to use it later (use the green button : )


Points of Interest

It is so funny how my friends kept asking for the source code of this project and I kept ignoring them (acting). It will be a good surprise for everyone (I hope), but it is great to see a lot of people who want to learn.


  • March 19, 2015: First upload


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Alaa Ben Fatma
France France
No Biography provided

Comments and Discussions

QuestionBatch IDE Pin
Hrvola10-Jan-18 9:24
MemberHrvola10-Jan-18 9:24 
AnswerRe: Batch IDE Pin
Alaa Ben Fatma10-Jan-18 9:32
professionalAlaa Ben Fatma10-Jan-18 9:32 
I made that application when I was 14 years old, a lot of things have changed since then!
...Thank you!
QuestionHow do i set it up? also did you use python to make this? Pin
Member 1338795231-Aug-17 10:20
MemberMember 1338795231-Aug-17 10:20 
AnswerRe: How do i set it up? also did you use python to make this? Pin
Alaa Ben Fatma5-Sep-17 13:08
professionalAlaa Ben Fatma5-Sep-17 13:08 
QuestionIDE? REALLY? Pin
nnnnki4-Aug-15 6:14
Membernnnnki4-Aug-15 6:14 
AnswerRe: IDE? REALLY? Pin
Alaa Ben Fatma6-Aug-15 7:21
professionalAlaa Ben Fatma6-Aug-15 7:21 
GeneralRe: IDE? REALLY? Pin
nnnnki7-Aug-15 20:29
Membernnnnki7-Aug-15 20:29 
QuestionBrilliant Pin
mtlabs24-Mar-15 3:07
Membermtlabs24-Mar-15 3:07 
AnswerRe: Brilliant Pin
Alaa Ben Fatma26-Mar-15 10:48
professionalAlaa Ben Fatma26-Mar-15 10:48 
AnswerRe: Brilliant Pin
nnnnki4-Aug-15 6:18
Membernnnnki4-Aug-15 6:18 
GeneralRe: Brilliant Pin
Alaa Ben Fatma6-Aug-15 7:22
professionalAlaa Ben Fatma6-Aug-15 7:22 
Generalthanks Pin
joyhen12312323-Mar-15 16:08
Memberjoyhen12312323-Mar-15 16:08 
GeneralRe: thanks Pin
Alaa Ben Fatma23-Mar-15 18:29
professionalAlaa Ben Fatma23-Mar-15 18:29 
Suggestionyou must improve the code and add more options Pin
Alberto M.21-Mar-15 1:31
MemberAlberto M.21-Mar-15 1:31 
GeneralRe: you must improve the code and add more options Pin
Alaa Ben Fatma21-Mar-15 4:24
professionalAlaa Ben Fatma21-Mar-15 4:24 
GeneralRe: you must improve the code and add more options Pin
EveryNameIsTakenEvenThisOne21-Mar-15 7:52
professionalEveryNameIsTakenEvenThisOne21-Mar-15 7:52 
GeneralRe: you must improve the code and add more options Pin
Alaa Ben Fatma21-Mar-15 10:18
professionalAlaa Ben Fatma21-Mar-15 10:18 
SuggestionJust and IDE Pin
Alberto M.21-Mar-15 1:30
MemberAlberto M.21-Mar-15 1:30 
QuestionMisleading Pin
EveryNameIsTakenEvenThisOne20-Mar-15 7:50
professionalEveryNameIsTakenEvenThisOne20-Mar-15 7:50 
AnswerRe: Misleading Pin
Alaa Ben Fatma20-Mar-15 14:13
professionalAlaa Ben Fatma20-Mar-15 14:13 
GeneralRe: Misleading | Edit: Vote of 2 Pin
EveryNameIsTakenEvenThisOne21-Mar-15 7:59
professionalEveryNameIsTakenEvenThisOne21-Mar-15 7:59 
GeneralRe: Misleading | Edit: Vote of 2 Pin
Alaa Ben Fatma21-Mar-15 10:09
professionalAlaa Ben Fatma21-Mar-15 10:09 
GeneralRe: Misleading | Edit: Vote of 2 Pin
EveryNameIsTakenEvenThisOne21-Mar-15 12:53
professionalEveryNameIsTakenEvenThisOne21-Mar-15 12:53 
GeneralRe: Misleading | Edit: Vote of 2 Pin
Alaa Ben Fatma21-Mar-15 15:33
professionalAlaa Ben Fatma21-Mar-15 15:33 
GeneralRe: Misleading | Edit: Vote of 2 Pin
EveryNameIsTakenEvenThisOne21-Mar-15 18:11
professionalEveryNameIsTakenEvenThisOne21-Mar-15 18:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.