While using the Windows machine we face soo much trouble running the command line scripts on CMD(command prompt). Few commands run successfully but some are not. Why is there any difference between terminal and CMD.
-
Can you clarify, what exactly do you mean by "terminal?" Note too there is the command processor (command prompt) which can be termed "CMD" and, there are the .cmd (Batch Files) which can be termed "CMD." See EduCBA: CMD vs BAT.– ScottWelkerFeb 24, 2022 at 0:10
-
The command prompt available in software development IDE like IntelliJ, Eclipse and VS code is called terminal.– RashidFeb 25, 2022 at 11:09
-
Thanks @Rashid. To be of any help we'd need specifics. Which "terminal" exactly is not behaving as expected and what, specifically, is the error or undesired behavior. You've tagged your question with both powershell and shell-script one is very specific, the other is general. Scripts developed for one will not likely run within the other. We need greater specificity.– ScottWelkerFeb 25, 2022 at 15:57
1 Answer
The question needs details, like what type of script you're attempting to run, and the specific errors you're getting.
Generally speaking, by default Windows Terminal launches a PowerShell interpreter (but can launch others), whereas cmd.exe launches a command interpreter that's much older and has no PowerShell functionality.
If you're attempting to run a PowerShell script, it needs to be in a PowerShell session (start either PowerShell, PowerShell ISE, Windows Terminal with a PowerShell tab, or if you really want to, you can run in a cmd.exe window by invoking powershell.exe -File MyScript.ps1
).
If it's a batch file, either interpreter can run it.
If it's a shell script, it's most likely meant to be executed on Linux.
-
Just to muddy the water further, remember. In Windows .bat and .cmd are different extensions for two different flavors of batch file. Feb 24, 2022 at 0:04