Is it possible to replace CMD with something else?

I have never studied the OS, so goodbye if it sounds simple or silly, but I'm curious if the cmd prompt can be replaced on Windows. I DO NOT ask for programs that actually do this, because I looked around and did not actually see it.

What I ask is 1) if in fact you can write a completely new program that will behave like cmd and 2) if you could replace cmd with it, assuming that it can perform at least all the tasks, which cmd does.

Because it seems that even programs that claim to be an update (cygwin, powershell, etc.) actually work in the same small black window. Maybe I just don’t quite understand how cmd fits into windows in general or something like bash really connects to Linux.

Does anyone want to direct me in the right direction?

+3
source share
4 answers

"This is a small black window" is a feature of the Windows subsystem "console". Applications in console mode get this window to a large extent for free and open for them (either Windows itself or executable libraries, I forget that) when they start from Windows, and not from the command line. (Console modes launched from an existing console tend to take the console of the parent process.)

, , , cmd.exe( , ), .

, cmd.exe. . , ( , cmd.exe), , .

+4

you can write an application that allows you to create and execute batch (.bat) files.

for example, let's say you use C # as your language. you can open a text stream to create files (.bat). then you can execute them as follows:

ProcessStartInfo CmdReplacement = new System.Diagnostics.ProcessStartInfo();

//choose a name and then arguments that you want to send to the command prompt
CmdReplacement.FileName = @"C:\testfile.bat";
CmdReplacement.Arguments = "1 2 3 4";

//if you use this property it will prevent a console window from popping up
pi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

//create new process and set starting information
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo = CmdReplacement;


//set this to tell you when the process has completed
p.EnableRaisingEvents = true;

p.Start();

//wait until the process has completed
while(!p.HasExited)
{
System.Threading.Thread.Sleep(1000);
}

//check to see what the exit code was
if(p.ExitCode != 0)
{
//some error occurred
}
+1
source

CMD.EXE is just a program. This is nothing special.

0
source

Source: https://habr.com/ru/post/1765024/


All Articles