-
Jan 10th, 2025, 03:20 PM
#1
Thread Starter
Fanatic Member
[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
-
Jan 10th, 2025, 10:27 PM
#2
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?
-
Jan 11th, 2025, 02:14 AM
#3
Thread Starter
Fanatic Member
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.
-
Jan 11th, 2025, 04:03 AM
#4
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.
-
Jan 11th, 2025, 05:00 AM
#5
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|