Results 1 to 5 of 5

Thread: [RESOLVED] Running a console inside a console

  1. #1

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    806

    Resolved [RESOLVED] Running a console inside a console

    Hi, I am trying to make something like cmd.exe in C# that allows you to run simple commands and execute them, what I want to know is it possiable to run an external console in my cmd console that it works like the real command prompt in windows can captures stuff I hope I have explained this so you understand, bascily I want to make like a sort of like dos env that run ontop of windows like cmd.exe does. I know in Linux there is something called fork() is it possiable to have something like that in C# consoles.

    anyway I hope you understand what I need an info or a simple example code will be greatfull Thanks

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    12,025

    Re: Running a console inside a console

    You can always run arbitrary cmd actions in a console via Process.Start then output the results in your Console Application. Is this something you're looking to do?
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    806

    Re: Running a console inside a console

    I am looking for something that is equivalent to fork() exec() used in linux, I am not very good at explaining things so I may have to mke an example to show you more. bascily what I want to do is in the main console is have it like an interpter that can run built in commands and also run things like other exe in the same processs. so if I typed dir it should show in the main interpter process or like if you know something like cmd.exe in windows already does I want to sort of make my own version of it. I know proess.start, I have to make something so you get a better idea.

  4. #4
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,638

    Re: Running a console inside a console

    Search for “terminal for windows” on github and peek at any .Net project which implements this - it’s very simple.

    Basicly you allocate a console in your process and use it as I/O device for all spawned processes. This way you get fancy stuff like colors.

    Another approach is to redirect spawned process I/O to files/pipes and show these to whatever window/target you want but this loses the fancy stuff console apps do like direct positioning and colors i.e. TUI stuff.

  5. #5

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    806

    Re: Running a console inside a console

    Thank wqweto I think I may have found something. also thanks dday9 for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width